Dear all,
i am trying to calculate absolute humidity from several relative humidity.
I want to use the absolute values in a blockly rule.
Therefor i created a blockly script to calculate the values, but i dont know how to call this script from a rule and give the scripts inputs (rel. humidity and temperature). Is this even possible with a blockly script?
Different approach was to use an inline script in blockly. But this is giving me very strange outputs:
As you can see the blockly calculation is correct, but how can i give inputs (temperature, rel. humidity) to the script from a rule?
Inline script calculates 10^2 = 8 (why??)
Hello, yes this is possible. But i want to work with the resulting absolute humidity values in my rule. For example compare 4 different absolute values with each other. In order to do this i need to give my script 8 different inputs (rel. humidity 1…4 and temperature 1…4) and get back 4 different abs. humidities (1…4). Is this possible?
It takes a “dictionary” which is basically a set of key / value that are forward to the rule and this can then be read on the receiver rule (“1_hello_rule”) with “Retrieve context attributes passed by a calling rule/script” Rules Blockly - Run & Process and Transformations | openHAB
The other replies have shown you that yes, you can call another rule from a Blockly script with inputs. However…
You don’t get anything back. It’s not a function call with a return value. In fact, I don’t think it even waits for the called rule to finish before the “run rule or script” block returns.
If you want to get a value back in a reusable function, you’ll probably need to create a Blockly Library (under Developer Tools). See Tutorial: How To Write Block Libraries.
In JavaScript, which is what Blockly “compiles” into, the ^ operator is a bitwise XOR. 10 XOR 2 = 8.
Do you mean 10*10 (i.e. 10 to the power of 2)? You’ll need to use Math.pow.