History_stats and a "cycle"

I want to create an automation that triggers after every 12 hours of an appliance runtime and sends a notification if a manual “button press” was NOT triggered.

In other words, say the appliance starts running (1st time ever) today at 6am and it turns on/off during the day and three days from now it’s run a total of 12 hours. I want my automation to trigger and check to see if within that period of time someone pressed a button (that’s also a device inside of HA). If the button was not pressed, then I’m going to send an email. If the button WAS pressed, I want the next 12 hour cycle to start from the time the button was pressed.

I’m pretty sure I need at least one history_stat monitoring the runtime time but I’m not sure how to configure the time period for it, or how to “reset for the cycle” I need…

Suggestions?

I think a riemann integral / utility_meter combo might be more appropriate than a history stats for this. History stats isn’t good for accumulating long term data as it is at the mercy of recorder purges.

To track runtime with riemann, you need a sensor that is “1” when the appliance is running and “0” when it is not. Then if you make an hourly integral, that sensor will be the “lifetime runtime hours of the appliance”.

Then you can use a utility meter on that sensor that gives you the ability to reset it as desired. So that sensor will be “appliance runtime since last reset”.

You can reset the utility meter whenever the “button” is pressed. If it goes above 12, fire your notification.

I’m kinda following this… But I’m confused on this part:

To track runtime with riemann, you need a sensor that is “1” when the appliance is running and “0” when it is not. Then if you make an hourly integral, that sensor will be the “lifetime runtime hours of the appliance”.

Can you explain the relationship between these two please? I have a counter and I can increment when the appliance runs and decrement when it stops… No problem there… So then I use THAT counter as input in the Hourly Integral sensor?