#Detect previous last_changed value?

1 messages · Page 1 of 1 (latest)

magic prism
#

When my tv turn on I need to check if it was off to at least 15s due to the fact that the integration is not super stable and sometime the sensor randomly switch on => off => on, re-triggering some automations, which is quite annoying.

The template condition {{ as_timestamp(now()) - as_timestamp(states.media_player.smart_tv_salotto.last_changed) >= 15 }} won't work as the automation is triggered when the tv switched from off to on, so it always return false.
Is there a way to check the previous last_changed value?

umbral notch
# magic prism When my tv turn on I need to check if it was off to at least 15s due to the fact...

you could template a binary sensor in the configuration file which follows the on/off entity state but has delay_off setting which means it wont switch to "off" until a set time has passed. then you can automate off of that entity instead.

documentation on this here - https://www.home-assistant.io/integrations/template/#binary_sensor

Home Assistant

Instructions on how to integrate Template Sensors into Home Assistant.

magic prism
umbral notch
#

awesome, happy automating 🙂

magic prism
# umbral notch awesome, happy automating 🙂

I'm facing a similar problem with a non boolean entity, and I don't understand how to write the template condition.
I want the binary_sensor to be true if the camera return state streaming, else false, but it always return false: can you give it a look?

- platform: template
  sensors:
    tizen_led_delayed_state:
      friendly_name: first_led_hardware_instance_delayed_state
      value_template: >
        "{{ states('camera.first_led_hardware_instance') == 'streaming' }}"
      delay_off:
        minutes: 2
umbral notch
magic prism
umbral notch
#

try this

  sensors:
    tizen_led_delayed_state:
      friendly_name: first_led_hardware_instance_delayed_state
      value_template: >-
        {{ states('camera.first_led_hardware_instance') == 'streaming' }}
      delay_off:
        minutes: 2```
#

i think it might just be a formatting issue. i remember that being a bit strange sometimes

magic prism
umbral notch