Logging of amount of time a switch has been on


#1

1) Give a description of the problem
I’d like to log the amount of time a switch has been left on and then publish that to somewhere outside of the piston itself. I was doing a daily summation of time however would like to log this somewhere.

2) What is the expected behavior?
I currently use fuel streams for logging internal / external temperatures and wondered if I could use the same mechanism to log the amount of time a switch is left on.

3) What is happening/not happening?
Looking for advice before I start building a piston.


#2

I’ve tried this appraoch and waiting for the logging to the Fuel Stream to take place tonight:

I’m open to any ideas of how to improve this piston. At the moment I’d need to duplicate this piston for each device I’d like to monitor. I would just update the device variable…

Thanks


#3

Your nested if switch changes to off will probably not fire. You can have it as it’s own top level statement