Trying to get a Template to a binary working

I have been banging my head on this all morning and I just can not get it to work.

  - platform: template
    sensors:
      front_door_state:
        #value_template: '{% if is_state("sensor.frontdoor_alarm_level_2_1", "255") %}open{% else %}closed{% endif %}'
        value_template: '{{states.sensor.frontdoor_alarm_level_2_1 | float > 0}}'
        friendly_name: 'Front Door state'

The commented out is what I was using but that will not trigger an action that has a “for:” delay I guess it’s only for binary sensors as I found in another post.

My door sensors report 0 for closed and 255 for open. The above to get a “true/False” is only giving me a “false” no matter what state it is in, and trying to use the “open/closed” that does work never ever triggers if I have the “for:” delay in the trigger. if I remove that it works.

so how can I get the door lights to turn off 10 minutes after the door closes? is there a way to get a value to become a true binary so I can use the “for:” delay as seen below?

- id: front_door_closed_light
  alias: FT_Door_closed
  trigger:
    platform: state
    entity_id: binary_sensor.front_door_state
    to: 'false'
    for:
      hours: 0
      minutes: 1
      seconds: 0
      
  action: 
    - service: homeassistant.turn_off
      entity_id: switch.patio_bulbs_switch_3_0

You only need, value_template: '{{is_state('states.sensor.frontdoor_alarm_level_2_1', '255') }}'.

I have the exactly the same sensor here. Hope that helps.

1 Like