Recognize inactive time longer than deep sleep

Hello,

I don’t have an idea for an implementation and can’t really find what I’m looking for when I google.
Maybe it’s just because of the missing keywords :wink:

Here is my desired implementation:
I have made EPS8266 circuit boards for battery voltage detection. They wake up for 10 seconds and then go back to deep sleep for 30 minutes.

In Grafana I display the progression and always use the last value. This gives me a continuous curve.

As is often the case with external ESPs. The boards sometimes lose the Wifi signal over a longer period of time or do not re-establish it, I sometimes do not receive any updated measured values for several hours.
But now I would like to know whether the signal is valid or not. In other words, when the last update of the measured value took place. I would then like to create a small traffic light next to the measured value.
E.g. green for the last signal received within the last hour, yellow the signal was received 3 hours ago or red for everything older than 3 hours.

To do this, I would have to query when the last measured value with which time stamp took place or simply when the last connection to the ESP took place.

Do any of you have an idea of how I can best implement this?

I look forward to your support.

Greetings
the Noblast

The ESPHome sensors should have last_updated and last_changed attributes that HA creates that you can work with further on the HA side (for instance create further template sensors from them).

(Edit: my use of the term attribute above is wrong here I think).

Search for those terms for more examples on the forum.

A Status sensor with a delayed_off filter could be another approach.

Hello Marko_Mahko,

thanks for your advice. Unfortunately, it took me a little longer to understand everything. I always thought that I can only see the attributes that I can see in the developer tools and states.

Now I have added the following lines in the Yaml Configuration and can therefore see when the last update took place.

template:
  - sensor:
      - name: "Aktualisierung CLK"
        unique_id: "Aktualisierung_CLK"
        state: >
            {{ relative_time(states.sensor.esp_clk_batteriespannung_batteriespannung_mercedes_clk.last_changed) }}

I still have to see how I can make a threshold value generator out of it, which gives me a warning about outdated measured values when a certain time is exceeded.

Many thanks and best regards
the Noblast

1 Like