I would like to set conditions like this in a query: {{value-0}} > {{ data.limit0}} .
I cannot use something like this:{{value-0}} > 90 or wherever other static value.
This condition does not work {{value-0}} > {{ data.limit0}} neither {{value-0}} > {{ limit0}}
How can I do that?
Thank you.
It looks as though you are attempting to compare a string and a number, which are not comparable.
If you’d like to compare the string and the number in the indicator block, you can accomplish it like so:
String and Number Block Comparison
I have a device with two attributes: airflow and humidity. Airflow is a string, and humidity is a number, so my state reads like this:
As you can see, airflow is less than humidity, but they are not yet comparable as airflow is a string. Within my indicator block, I have set humidity to value-0, and airflow to value-1.
To compare these two, I must change value-1, which is currently a string, to a number. To accomplish this, I use a helper within my indicator block called “add” which casts both values as numbers and adds them. I “add” zero to my string, and the string is now a number that is comparable with value-0!
Hi Julia
Thank so much for your suggestion.
I implemented it in the way I show in the attached pic but does not work, always the indicator block remain as green even limit0 is in the payload.
The first is that variables are only available when they are pulled in within the Block Data section. You are pulling in attribute “value0” at Query 0 and it’s value is then available at {{value-0}}. To use “limit0”, you will need to do the same thing, as shown below:
You will then be able to use the “limit0” value, and it is accessible at {{value-1}}. I replicated your use case, and this is what it ended up looking like:
The last difference between this case and yours, is that you have your “duration” set to “live stream,” so data will only show when it is live. I have set mine to “last received data point” so it will show the last available value for the data.
The last suggestion you gave me does work, thank you.
There is a down side, which is that {{value-1}} is not updated despite
I can see it in the debug tab that its value, limit0 is being updated constantly.
I can verify that the indicator block works, because I set {{value-0}} to a lower value that {{limit-1}}
and the block color get green.
In addition I set up duration to "Last received data point ", otherwise the block does not change the color.
The value that take value-1 is current value it has at the time I create query 1.
After that I move the slider and set the value but nothing happens.
I took a look at your workflow and it looks as though you are never updating the value of limit0. Inside of your device state node, you are only setting the state of three attributes within your device: value0, value1, value2. See below: