Node Red Counter

Hey, I need some help.

Using the node red custom integration I want to have a shower timer/counter.

I use this:

Now I am struggling to select the right fields in the sensor node.

I would like it to show seconds in HA. Current settings:

I hope I explained well enough…

The number shown under shower time is a ~current full time stamp. It looks like you’re just passing the inject nodes time stamp. That number is how many milliseconds since 1970. I dont think that is what you want in seconds.

If the start time is saved somewhere, then the difference between the two will be the running shower time.
These states are normally saved as a number, which is the number of second, milliseconds or similar since a specific date.
If you save the start time and the running time in the same program, then the specific date will be the same and the unit will also, so just subtract the running time from the start time.
HA can convert these time numbers to a normal formatted date, but HA might have another unit, so you might have to mulitply or divide with 10,100 or 1000 to get the right conversion…

exactly, but what do I need to do to get only seconds?

I forgot to tell a part of the config:

I count the “succesfull seconds”

this may not be exactly what you are looking for, but should point you down the right path. also presumably gets rid of the need to poll a device every second.

it uses one of my favorite nodes, stoptimer-varidelay.

the bottom outputs time in normal format

check out the filter config in particular. i also just noticed i left the state as string, that should be number

flow for import: debian Pastezone

What is the end result? What do you want to see?

Do you want a running timer you can see increase in seconds on the dash?

When the water stops, does the time go to zero? Or do you want it to add to the timer and reset at the end of the day? ie total water use for the day?