Not sure if i need a rule or app

Hi all I have an idea I am not sure if I need a rule or an app
I have a zooz zen 15 power plug on a sump pump
I need to track when it runs and for how long
then I like to have that on my dashboard
I can read the power attribute to see when it is above 150 w to known the pumps is on
I do not know how to figure how long is on
thanks, beau

Are you looking to track each period it has run for in the past, or just how long it has currently been running?

If you want historical records you may need to look at some sort of data capture outside of HE. I use InfuxDB and Grafana on a raspberry pi, but if this is the only use case you have, that kind of setup would be overkill.

If you only want the current run time there are probably a few options, and others may have better ideas than me, but I expect you should be able to achieve it with a rule or rules that are triggered on a change in state of the plug, i.e. when the energy goes above 150 or below. This approach would also be reliant on the energy being relatively stable while the pump is running, i.e. not jumping around too much, though you can handle it by detecting those conditions being true for multiple readings.

To detect how long, I can't be 100% sure how best to do that.... Perhaps as a start if you can put the date/time a rule was triggered into a global variable, you could at least show that on your dashboard? I'd have to play around with a rule some more to work it out...

As another idea, I'd play around with some of the apps that provide timers and see if any support being triggered by another device. If one does, you could have a rule that detects the change in energy usage and have the rule flick a switch that starts / stops a timer. Not sure if an app like this exists, but even if one doesn't, you could ask one of the developers to update one.

you could do a rule to do this, and it can track in your logs

Trigger: pump turns on
Actions: log message "pump on"
wait for event 'pump off'
log message "pump off"

alternatively you could use local variables to track the on/off times, and look to do some arithmetic on it and store that value in a third local variable. then display that local variable on your dash. (i don't think the variables will automatically update though, but they will refresh and show the value at the time of loading the dashboard)