can i do this in rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
GravityRZ
Normal user
Posts: 154
Joined: 23 Dec 2019, 21:24

can i do this in rules

#1 Post by GravityRZ » 22 Jan 2021, 14:47

not sure if this works

i know i can compare 1 or multiple variables but am not sure if i can do calculations


on MQTT#value do

if [AAA#Total] - [BBB#Total] =1
do your thing
endif

Endon

TD-er
Core team member
Posts: 4270
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: can i do this in rules

#2 Post by TD-er » 22 Jan 2021, 15:16

The calculations are not (yet) working everywhere, so it is best to store them in a variable first as the "Let" command (to store some value in a variable) is for sure calling all calculation functions.

Then you can compare based on this variable:
if [var#1] = 1 .....
or using the "int" representation of that same variable:
if [int#1] = 1 .....

N.B.
The recently introduced functions with {} are parsed first (just like %eventvalue%), before the calculation functions are called.
This means that if you need to calculate something first before you can use it in such a {} function, you should store it in a variable first.

GravityRZ
Normal user
Posts: 154
Joined: 23 Dec 2019, 21:24

Re: can i do this in rules

#3 Post by GravityRZ » 22 Jan 2021, 16:11

thanks.

changed the code so i can only check on 1 variable [VAR#2]

lagidnyj
Normal user
Posts: 3
Joined: 19 Jan 2021, 23:04

Re: can i do this in rules

#4 Post by lagidnyj » 26 Jan 2021, 09:00

Good day. to not start a new topic, tell me.
I need to send a number in 3 character format like 071, 007 to the server.
71 or 7 is in this case the value of the temperature sensor.
can I create a rule with a dummy intermediate device with conventions where the result would be the addition of zeros?
let's say so:
...
TaskValueSet,3,2,00[BME#Temperature]
...

User avatar
Ath
Normal user
Posts: 565
Joined: 10 Jun 2018, 12:06
Location: NL

Re: can i do this in rules

#5 Post by Ath » 26 Jan 2021, 09:59

The value for TaskValueSet is stored in a type float variable, so any prefixing zeroes will get lost/ignored immediately.

Have a look at the formatting & justification feature of the variable expansion that you could apply when sending to a (external?) destination, documentation is over here

Edit:
You could use something like this:

Code: Select all

  ...
  SendToHTTP,externalhost.com,80,/url/with?value=[BME#Temperature#D3]
  ...
/Ton

lagidnyj
Normal user
Posts: 3
Joined: 19 Jan 2021, 23:04

Re: can i do this in rules

#6 Post by lagidnyj » 26 Jan 2021, 14:22

thanks for the hint! it seems that this is just what is needed. I'm still a new user, and it's hard for me to understand. but I figured out what I needed to do! :D

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests