Calculate energy per day

I use a Aeon Labs HEM to measure energy. I want to calculate average kwh per day, so want to set a global variable to display on a dashboard tile. I created the global variable, and since apparently attributes from devices cannot be used directly, I created two local variables in a rule: one for energy attribute from the hem device, another for number of days since reset. The action would be to set a global variable from total energy divided by number of days.

When I create actions, I am able to set the appropriate local variable to energy, and I can set the global variable to be displayed to a calculated value that should be the above ratio. It all works as expected except for one hiccup: the attribute for number of days, “energyDuration” does not show up in the list of attributes! The duration attribute is otherwise present, and I display it in a tile on the energy dashboard, but it’s not in the list of attributes for the device when I try to set the rule local variable prior to calculation.

Am I not understanding the variables setting, or is this a bug?

Sounds like you haven't found the Custom Attributes in RM. Any attribute that a device driver exposes can be accessed via RM it's just a matter of digging a little to find it.

2 Likes

I find custom attributes in triggers, but that's not what I want. I want custom attributes in device attributes of actions. These are available elsewhere, such as in dashboard tiles:

I want to access this value in actions to transfer to a local variable:

What appears to be the case is that the particular attribute is a type "TEXT", which can't be used in an equation, as there is no means that I can see to extract a DECIMAL from a string. Is there some other way to collect the value?

Note that I presently just plugged in the value "cost" to have something to calculate in order to test the action. But it's a nonsense result, so I need to get the numeric value. Perhaps as a last-ditch effort, I could modify the driver (it's a third-party) to set an attribute to that value...?