Sensor delay possible?

Hello, I have a template sensor that reads the brightness level of my living room light and converts that to text, depending on which scene the light is set.

    livinglightstate:
      friendly_name: 'Living Brightness'
      value_template: >
       {% if is_state('light.living', 'off') %}
       Off
       {% elif states.light.living.attributes.brightness | float < 60 %}
       Away
       {% elif states.light.living.attributes.brightness | float < 110 %}
       TV
       {% else %}
       On
       {% endif %}

The sensor works fine and everything, but it’s a little bit annoying that when it changes state from Off to On (fades in over a few seconds) it goes through all the other options so the history looks like Off, Away, TV, On. Is there a delay function/condition it must pass through before changing the state? Say it needs to remain in one particular state for 5 seconds before it changes status? Something like the delay_on/delay_off setting that’s available on the binary sensor?

Cheers

4 Likes

I’m also interested in any kind of solution for the above

Any news on this? I’m looking for the exact same thing.

1 Like

Okay, why don’t you have an automation that triggers on the sensor changing.
In the action section set an input text to " " (a space or empty string) then have a delay (say) 10 seconds. Then update the input text with your delayed response.
You can create another sensor displaying the text or just use the text direct

iam really curios why this isnt a thing yet

Has there been any change to this? I also need to add a delay to a template sensor before it updates. Basically need the same as delay_on that is available for a template binary sensor.

With trigger-based template sensors, you decide yourself when the sensor is updated.

1 Like

Great. Thanks. It looks like I have managed to solve this by adding the following trigger to the template sensor:

- trigger:
    - platform: state
      entity_id: sensor.name_of_sensor
      for: 00:00:01
    - platform: homeassistant
      event: start
    - platform: event
      event_type: event_template_reloaded