Count all recieved seconds of today

From TTN i receive data from my sensors and one of them is AirTime (example 0.051265 in seconds).
How can I add them together for today to show the total Airtime?

can this be done with a template or should I use an automation to reset the value at 23:59?

Looked like it was working, now i face the issue that the airtime is the same for a few update in a row.
I get the data through MQTT in Node-Red and that uses the HA integration. The sensor is updated every 15 min (checked the debug window in Node-Red) with the same value. Because of that HA does not update the last-updated.

Does this have effect on the utility-meter sensor?
Because it doesn’t count the received values, it stays at the last-update time

image

is that expected behavior or am I doing something wrong (not a HA expert)

I don’t use the utility meter so I’m not sure if it’s normal or not.

Does the value at the end of the day match the expected value for the actual airtime? if so then I wouldn’t worry about it.

Unless I’m not understanding what you need out of the sensor…

No it acts wierd.

The TTN (LoraNetwork) allows me to use a maximum amount of transmit time (airtime) during 24h.
When I receive the data object through MQTT it has the airtime component in it that show the used airtime for that transmission. (the lorasensor sends it data to the TTN network and that then sends me a MQTT message.)

What I want to do is show the current airtime (from the message) and show the total airtime of that day, basically counting all the airtime’s together and reset to 0 after 24h.

To see if the lorasensor is still alive (when values remain the same HA does not show this as an update) I added a counter that increases with every transmit the sensor does. This allows me to detect missing transmits. The counter is nicely increasing while the airtime (and other values) remain the same with a last_update in the past (sometimes hours). The actually received values are there, just the same as the previous ones.

When I look in InfluxDB or HA history is see the counter increasing, the airtime has a more square structure and flat lines.

the total_airtime does not count up. below is a screenshot of the current values

image

The average airtime is 0.06 seconds every 15 min. after 2 hours that should be 8x 0.06 = 0.48

That sounds like a quirk (aka bug?) in how HA handles last_updated then.

I thought it should change last_updated when it received new data even if the data was the same but it only updated last_changed if the data actually was different.

Again I don’t use the utility meter but I would think it should care about the actual data sent during the last_updated not if the actual value received had changed.

Unless I am misunderstanding what is happening then it definitely sounds like a bug.

To help someone troubleshoot this you should post your utility meter config here too. Maybe there is something incorrect there.

And unless someone who knows more than me pops in here and answers the question then maybe submit a bug report (issue) and see if it can get resolved in that way.

It turns out that the Utility Meter is not designed to work like this.

Looking at the developer tools it looks like the last_updated and last_change are working fine.

1 Like

OK, I guess the correct sensor to use would be the Riemann Sum sensor and not the Utility Meter sensor.

:wink:

The Utility Meter seems to be very poorly named.