Hello, my device has three boolean alarm attributes.
I added an indicator block on my dashboard and setup three queries to pull the values of the alarm attributes. I use this expression to set the block color:
({{value-0}} || {{value-1}} || {{value-2}})
I would like the block label to say “X Alarm(s) Active” when I have active alarms.
I’m not sure what language I would use in the label field to count how many of the values are true. Any assistance would be appreciated.
Thank you in advance,
John
Am I on the right track with this?
{{#each data.queryResults}}
{{#if this}}
{{@index}}
{{/if}}
{{/each}} Alarms Active
Hi @John_Hart, and welcome to the Losant Forums!
The {{add}}
helper will cast your booleans to numbers so, assuming true
means an active alarm, you could get what you are looking for with something like this …
{{add value-0 (add value-1 value-2)}}
The part in parentheses is a sub-expression since the {{add}}
helper only takes two arguments; we’re just running the helper again inside of there to add the last two values and taking that result and adding it to the first value.
Let us know if you have any other questions, and again, welcome to Losant!