I’m looking to build an automation for my boiler switch, which involves checking its “on” durations/the last time it was “on” in the last X times. I’ve History Stats, but I always like to inspect things in the Template in Developer Tools. However, when I do:
{{ states.history_stats|length }}
I get 0. Which means this object doesn’t contain any members. How can I inspect it anyway?
History_stats is the integration, it creates sensors, so you need to insoect rhe sensors you created, there are now history_stats.xxx entities, that’s why your command shows 0.
I’m sorry I misunderstood what you explained, but I don’t understand your frustration, I guess your typo threw me off just a little bit?
there are now history_stats.xxx entities
I stated my end goal in the OP. I want to check history_stats, given device sensor.entity_id, I want to inspect its history to see if I should perform a certain action. I wanted to see what kind of data is available through the template editor - thanks for answering my question.
I don’t understand what you want to debug here? Just click on the entity and you see the history for this entity. If you want more dou can also always use some SQL commands to extract the necessary data from the database.
Personally I use grafana to display history of my entities.
For this specific use case you can create a history_stats sensor for your boiler, with end = now and start = now - 4 hours and you should be good to go.
It’s always useful to see things in the editor than blindly writing in YAML files and hoping what I’m doing makes sense. It’s sometimes also useful for poking and discovering new features.
What if I want to check if it hasn’t been on for more than an hour in the last 4 hours?
I know grafana, it would be interesting if it opens new possibilities…
Thanks @Burningstone. Maybe I’m being slow but what this will create is basically a sensor that looks at the last 4 hours, and whose unit is hours? And THIS is the conditional I use in another automation?
@Burningstone one last question: can I give the sensor a custom name that doesn’t depend on its “Name”, in the future I may want to change the durations and the title of this sensor, but I’d like it to keep its ID. Is that possible?
But in this case the “name” field in the sensor in your previous post still determines the ID. What I want is the opposite. Should I give it a name like “boiler_on_hours_last_x_hours” and just override in the UI or through customize as you show?
Yes, this will be the entity_id. This is the one you want to stay, because you use it in scripts/automations etc. Then customize the friendly name, which will be shown in the frontend, through the UI or as I showed above.
Thanks @Burningstone! learned a lot here. Now just need to understand how I can manipulate the value reported (originally in hours) if I want to display minutes in a glance card…