The value of battalarmSet was not Boolean (true or false) but a String ("true" or "false")—I changed the type of battalarmSet to Boolean, but it's still not working.
Hello, I think you are using the wrong attribute, I believe the correct one in your case should be "power" instead of "batteryLevel", since the "batteryLevel" attribute returns a percentage (10%, 32%, 100%)
Hello Thank you, but the batteryLevel only gives me numbers
What is a number to you?
in this case 0-100
Okay, that's correct. And why can't you use the "power" attribute?
Another thing you are using as a string, you should use it as a number.
The problem is that the alarm triggers every time the battery level is less than 10 but greater than 0.
Why is that a problem and how your new expressions are supposed to fix it?
Hi Anton, thanks :
batteryLevel < 10 ? "lowBattery" : null
i test it and response
I don't think it answers any of my questions.
With the new expressions I wanted to achieve that when the alarm was set it would be saved and only reset when the battery level increased again
Not sure how you expect it to work. You never check last values, so it will obviously not work.
Hi everyone,
I'm having an issue with Computed Attributes and hope someone can help.
I'm trying to set an alarm for low battery using the following expression in Computed Attributes:
alarm
Expression:
(batteryLevel > 0 && batteryLevel < 10 ? "lowBattery" : null)
Type:
string
The problem is that the alarm triggers every time the battery level is less than 10 but greater than 0.
To fix this, I tried the following two expressions:
Attribute:
alarm
Expression:
(batteryLevel < 10) && (battalarmSet == false) ? "lowBattery" : null
Type:
string
Attribute:
battalarmSet
Expression:
alarm ? (alarm == "lowBattery" ? true : battalarmSet) : (batteryLevel >= 10 ? false : battalarmSet)
Type:
string
Unfortunately, with the second expression, the alarm doesn't get set at all. Does anyone have a solution or know what I might be doing wrong?
Thanks in advance!