I have an automation which records (to a text file) each time my boiler’s burner state changes (on or off.)
I use this data outside HA from time to time to calculate various things. The first step is always to calculate how long it lasted, each time the burner was “on.”
Obviously the automation is able to access the from_state and to_state. What I want to know is how long the entity had remained in the “from” state before the state change. In other words, how long since the last time the state changed (which would also be how long since the last time this trigger fired, if that helps.)
Any ideas on how to do this in HA, so I don’t have to do it later, when I go to analyze the data?
I didn’t know there was a last_changed time associated with both the from_state and to_state. That seems like the most straightforward way to go. For the record, my automation now does this to write to the text file:
Update: data_template: has been deprecated, and the whole notify to a file thing has changed. This is what I think I’ll need to do when I update to 2024.6.x: