I’m unable to perform a math operation on a history stat. I basically want to add together two times. One that corresponds to HVAC cooling time and the other HVAC heating time. I’m pulling the Y1 cool time and Y1 heat time without issue, but if I try to perform math on it I get failure. This is what I’m trying:
I tried at first to add the time without the float conversion, and it basically just concatenated the times. Then I tried the float conversion, but the conversion just lead to 0.0, so the math operation just returns 0.0 + 0.0 = 0.0.
Could some give me a recommendation, on how I can add these two times?
The reason why it fails is because the sensor’s value attribute contains a non-numeric string.
I have a History Stats sensor (for heating hours) and value looks something like 2h 32m. You can’t perform an arithmetic sum of two non-numeric strings and you can’t use the float filter to convert a non-numeric string.
Use the sensor’s state because that’s a numeric string which can be converted by float.
Thanks for help, that worked great. I’m actually trying to build a cumulative HVAC fan run time, such that when I hit 300 hours (for example), I get message/sensor flag to change to the air filters. Depending on the time of the year, this could take several months to expire, so I don’t want to attempt to keep standard history stats for that long. Also, I have a multi-stage heat pump with zoning, so determining run time on my HVAC is a bit complicated. I’ll reach out for support, if I get stuck again.
Please consider marking my post (above) with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has an accepted solution. This helps other users find answers to similar questions.