Page 1 of 1

can i do this in rules

Posted: 22 Jan 2021, 14:47
by GravityRZ
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

Re: can i do this in rules

Posted: 22 Jan 2021, 15:16
by TD-er
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.

Re: can i do this in rules

Posted: 22 Jan 2021, 16:11
by GravityRZ
thanks.

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

Re: can i do this in rules

Posted: 26 Jan 2021, 09:00
by lagidnyj
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]
...

Re: can i do this in rules

Posted: 26 Jan 2021, 09:59
by Ath
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]
  ...

Re: can i do this in rules

Posted: 26 Jan 2021, 14:22
by lagidnyj
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