Computed Attributes - one overrides the others?

myxty4 years ago

Hi guys,

I'm having a question about Computed Attributes. I'm using Android mobile phone Client and let's says I want to get the alarm when my battery comes to 29% and another one when my battery comes to 28%.

So I made two Computed Attributes:
Description: Bat29
Attribute: Alarm
Expression: batteryLevel = "29.0" ? "Battery_is_29" : null
Type: String

Description: Bat28
Attribute: Alarm
Expression: batteryLevel = "28.0" ? "Battery_is_28" : null
Type: String

So when my battery is on 29% I get this into the database:
Attributes: {"batteryLevel":29.0,"distance":0.16,"totalDistance":13680.53,"motion":false,"alarm":"Battery_is_29"}

And I do get the Alarm in the State Panel:
Description text

But then when my battery is on 28% I get this into the database:
Attributes: {"batteryLevel":28.0,"distance":1.2,"totalDistance":13681.73,"motion":false,"alarm":"Battery_is_29"}

And I still get the old Alarm in the State Panel:
Description text

Then I unlinked the Computed Attribute Bat29, so I only have Bat28. I get the right entry to the database:
Attributes: {"batteryLevel":28.0,"distance":0.16,"totalDistance":13683.23,"motion":false,"alarm":"Battery_is_28"}

And right Alarm in the State Panel:
Description text

Why is it like this? Am I doing something wrong? How can I have two different Computed Attributes linked, enabled and get two different Alarms?

Thank you,
Mike

Anton Tananaev4 years ago

You have to use == for comparing values. Single = is an assignment operation, not comparison.

myxty4 years ago

Yes, thank you.
Now I get two different alarms.
Mike

myxty4 years ago

When User_A will enter his Custom Attributes for his devices, is it somehow possible for other users to use the same ones, that User_A entered? So they don't need to enter the same ones again?

Anton Tananaev4 years ago

Computed attributes are applied to devices, not users.