Iâd create a number helper (maybe call it daily boiler ons). then add an action to the reset script before the actual reset that sets that input helper to the counter value. The only someone tricky part is that you canât set a number helper to another state in the GUI. You have to use the YAML editor. It would look something like this:
I donât understand where âstates(counter.how_many_ons_125_boiler)â comes from.
I think the code takes that value and assigns it to the variable âdaily_boiler_onsâ â is that right?
Seems the more I learn about HA, the more I discover how much more I donât know. (And the amount I donât know if growing much faster than the amount I know.)
This tells HA to get the value of the counter you created and convert it to an integer. I copied the name right from the YAML you provided of the counter. So yes, the YAML I posted would assign the value of counter.how_many_ons_125_boiler to input_number.daily_boiler_ons right before the script resets the counter.
Note that I made a small update to the YAML I posted, as I didnât have the name of the entity enclosed in single quotes in my example, so it wouldnât work if you copy and paste it. I fixed that.
I suggest using the History Stats integration to do that. Then use the History Stats sensor with the Utility Meter integration to keep track of daily/weekly/monthly/yearly data.
The data produced by the Utility Meter integration is stored in a database table thatâs never purged (unlike other data thatâs purged, by default, after 10 days).
I tried to create a Utility Meter but I could not set the Input Sensor to a binary_sensor.
I have these binary_sensors (binary_sensor.125_1st_fl_heat_graph_binary and binary_sensor.125_2nd_fl_heat_graph_binary) that are created by templates such as:
Thereâs no such âguidelineâ. If you only want to use integrations that are configured via the UI, youâll lose access to a lot of useful integrations.
Instead of a History Stats sensor, you can create a Trigger-based Template Sensor that counts the number of times either of the two binary_sensors turns on (and resets the count at midnight). However, that also requires configuring it in YAML.
If you refer to its documentation, itâs designed to work with a sensor.
Hereâs a Trigger-based Template Sensor that counts the number of times either of the two boiler binary_sensors changes state from off to on. It resets the count at midnight.
In another thread where I am the OP, and in so many other threads, there are discussions of how the HA developers are moving away from configuration.yaml towards doing everything in the UI. This is partially evidenced by the new features (Helpers, for example) that, when created in the UI do not create an entry in configuration.yaml. Thatâs where I got the âguidelinesâ thinking.
But, I am glad to hear my understand is not correct.
As much as I am overhwhelmed by configuration.yaml, when I do learn how to accomplish something with configuration.yaml, I do really like the power of it.
There is a very easy and user friendly way to achieve what is asked above âŚis to use the measureit component, does almost everthing what you need in the UI.
Thatâs a guideline meant for integration developers. Itâs not meant to discourage people from using existing integrations that are configured via YAML.
If you have the time, I suggest you try the examples I posted above.
I set this up and I donât know if itâs working. So far, 125_boiler_count_today has a value of âunknownâ despite the binary sensors changing to ON.
When I put this code into the Developer Tools | Template tester, it results in the error: "â âtriggerâ is undefined "
Thatâs not a good sign. If it reports unknown it implies it hasnât been triggered yet.
Itâs using the same State Trigger you have in your automation with one small difference.
It triggers only when the binary_sensorâs state changes from off to on.
Your version of the State Trigger detects a state-change from anything (off, unavailable, unknown) to on.
However that small difference shouldnât prevent the State Trigger from working in this situation.
Iâm assuming you executed Developer Tools > YAML > Reload Template Entities after you created the Trigger-based Template Sensor (you must have, otherwise sensor.125_boiler_count_today wouldnât exist).
Check the Log for any related errors.
You canât use the Template Editor to test a template that references the trigger variable. That variable doesnât exist outside of the Trigger-based Template Sensor. The same applies to the this variable.
Logger: homeassistant.helpers.sensor
Source: helpers/trigger_template_entity.py:208
First occurred: 6:52:12 PM (5 occurrences)
Last logged: 9:28:13 PM
Error rendering state template for sensor.125_boiler_count_today: TypeError: can only concatenate str (not "int") to str