Zooz energyDuration and math

tagging @agnes.zooz

I want to obtain the avg consumption of devices connected to my Zooz power Z15 (or Zooz strips too btw).
2 data are available: energyDuration (XX days) and energy (decimal).

I set a rule that do some basic math:
I created 2 local variables: Zooz.fridge.days (decimal) and Zooz.fridge.energy (decimal) and 1 global variable: Zooz.fridge.Wavg

The idea is simple: Zooz.fridge.Wavg = Zooz.fridge.energy / Zooz.fridge.days

But I blown my rule because Zooz.fridge.days was defined as a decimal but the energyDuration is in fact a string (because of the word Days)

So, Agnes, is it possible in a future firmware to change the energyDuration from string to decimal (and forget "Days", we know that fact), so we'll be able to make some math on it ?

Question for others: is it a better way to create that rule ? I didn't find a way to do math on 2 devices attributes (global = deviceAttribute1 / deviceAttribute2) without using local variables (and obtain the result by global = local1 / local2)

I'm using C-5, V 2.1.5.124

Thank you
Mike

Would you be able to specify which report from the switch should be different? The variables available on Hubitat as triggers were set by Hubitat when the device was integrated so I'm not sure if there is anything on the device side that we could change in relation to the rule but maybe I misunderstood. Please let me know and we'll do our best to make it happen!

Hi Agnes and thank you for coming back to me.
I'm talking about one parameter called energyDuration (see pic) that measure the time (in days) the unit was on.
I don't know yet if this parameter for Zooz is a number only (in my case 129.4) or a string (129.4 days).
If I want to do some math on that value, HE doesn't allow to extract values from strings (aka extract the value 129.4 from the string "129.4 days").
So I ran an error because I tried to divide the total energy measured (in my case 156.444) by the amount of days (129.4), but in fact I divided a number (156.454) by a string (129.4 days), resulting an error.

So my question is to know that: does Zooz set that variable energyduration as a string OR as a number and Hubitat driver added the word days and transformed the number into a string.

If it's Zooz, my suggestion is to keep that value as a number so we can make math on it (and we can add the word "days" if we want to).
If it's not Zooz, I have to ask HE team to modify (...) this driver and keep the zooz energyduration as a number.

Better explanation ?
Thank you
Mike

zooz%20states

I have never tried this with ' ' (the spacebar as a Delimiter) but it seems like it should work. I use this often.
An existing example:

1 Like

@PPz It's worse than you think. It goes from minutes, to hours to days. It's inconsistent with most other things in hubitat, and I ran into it when I started exporting data with the MakerAPI and parsing that energyDuration failed all other rules.

I really don't understand why it just ins't seconds (or minutes) and calling it done. :frowning:

2 Likes

That's a custom attribute in the driver so it has nothing to do with what the device is actually reporting.

This driver was created before Rule Machine supported custom attributes so I'm assuming it was implemented like that to make it easier for users to read.

I'll upgrade an updated spare hub to test this. But I don't get your comment. Do you mean that the result of your math is inconsistent and the result varies spontaneously ?

Ok, I verified. The string itself changes. Could be "XXX Minutes" or "YYY Hours" or "ZZZ Days".

ok, that means Zooz reports only a value and HE transform it into a string.
I have then to test the latest HE firmware to see if I can extract the value out of this string.

Can't you use energy being set to 0 as a trigger to store the time in a global variable and use that variable in your calculations instead of trying to parse it from the driver's custom attribute?

Hmmm, interesting. So, reset the energy of the Zooz device by rule, measure my own time and measure the energy consumed in my own time frame ?

tagging @agnes.zooz (problem solved)

I created a simple rule to obtain the hourly avg energy measurement.
Is it a way to do the same with a variable like * value of the present day* ?

I can add in a daily rule 1 to a global variable to obtain it, but I didn't find a built-in variable to do so. I want to obtain a monthly measurement of some devices, better than an hourly

Update: Created 2 rules: 1 monthly reset (with a global variable Day.of.the.month), 1 hourly energy update (with a global variable Zooz.fridge.Mavg.kWh). should work


1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.