Hey all, I’m sure this is simple but I can’t quite get my head round it.
I have a climate/thermostat entity. It’s ‘state’ is always ‘heat’ whether or not it’s actually ‘heating’ or not. (Probably the way the Nest works, dunno…)
It has an attribute of ‘hvac_action: off’ which changes to ‘hvac_action: heating’ when it’s actually heating.
I want to create a timer based on how long the ‘hvac_action: heating’ has been on for the day. I realise I need to create a sensor in configuration.YAML. Happy to do this. But I can only work out how to track a ‘state’ - which won’t work for a Nest thermostat - as I said, it is always saying ‘heat’.
What can I ‘add’ to my YAML (below) that will track an attribute of an entity (in this case ‘hvac_action:’) ?
Once you get that working, you might consider using it with the Utility Meter integration so that it can record long-term stats for daily/weekly/monthly/yearly heating hours. For example:
utility_meter:
heating_time_daily:
source: sensor.heating_today
name: Heating Time Daily
cycle: daily
heating_time_weekly:
source: sensor.heating_today
name: Heating Time Weekly
cycle: weekly
heating_time_monthly:
source: sensor.heating_today
name: Heating Time Monthly
cycle: monthly
heating_time_yearly:
source: sensor.heating_today
name: Heating Time Yearly
cycle: yearly
If you use the Utility Meter integration, its sensor data is stored within the database’s statistics table which is exempt from the regular automatic purging cycle.
All other data is purged according to purge_keep_days (default is 10 days).
Setting it to 31 means data older than 31 days is purged.
Thank you for your quick reply. Since September I’m monitoring the tv runtime by using the model above (history_stats, 4 utility_meter-sensors and notify.FILE). And I want to get sure, that the data can be collected for one year. As I wasn’t aware of the fact, that the data is stored in separate ways I set the purge_keep_days period to 31 to save at least the data for every month.
Thanks to everyone on this thread as I’ve managed to get this working for all my panel heaters. Does anyone know how I can convert the time value into kWH? Each of my heaters are 1000W so should the math is pretty easy…just not sure how to do this in HA?
Hey! Sorry for jumping on this thread… I’m trying to do the same but can’t figure this out! I’m a bit of a newbie with Home Assistant and coding, etc.
I’ve got the first box of code working with my Templates page on Home Assistant and my own thermostat entity but I’m not sure how you reference the template sensor in history stats? Is that on the same page as templates - do I put that code with my entities in that page?
Sorry for what is probably a really obvious question!
But after saving and reloading HA config those new entities don’t show up anywhere. If I try to create a utility helper I don’t have the option to select those history_stats entities. Am I doing something wrong?
Edit: in case anyone else had the same issue, I was being dumb… Didn’t realise you had to do a full restart not just a YAML reload.