Trigger fails to turn on light

Hi,

I have a z-wave door sensor that I want to use to switch on a light. The sensor is detected and has series of different entities which display in the front end and change appropriately as the door is opened and closed. The light is connected and switchable.

My config passes checks and automation is displayed in the front end. Triggering the automation manually switches the light on or off but it does not seem to trigger via the sensor despite the state change. I have tried using different trigger techniques on different entities associated with the sensor, I suspect I am missing something obvious!

My automations.yaml is as as follows:

- alias: 'Hall Light on'
  trigger:
    platform: numeric_state
    entity_id: sensor.door_access_control
    below: 23
  action:
    service: light.turn_on
    entity_id: light.main
     
- alias: 'Hall Light off'
  trigger:
    platform: numeric_state
    entity_id: sensor.door_access_control
    above: 22
  action:
    service: light.turn_off
    entity_id: light.main

The z-wave sensor in the front end displays Door access control and the value is 23 when shut and 22 when open, the entity id used above is the new entity id but I have used the old entity id as well.

I have also tried using a different entity associated with the sensor, the binary sensor

binary_sensor.door_sensor

with a different trigger mechanism:

- alias: 'Hall'
  trigger:
    platform: state
    entity_id: binary_sensor.door_sensor
  action:
    service: light.turn_on
    entity_id: light.main 

and various other ways but I just can’t work out what I am doing wrong! Any assistance greatly appreciated.

I just had the same problem. Do you by chance have the Ecolink Door / Window Sensor (this one: https://www.amazon.com/gp/product/B01N5HB4U5)?

I finally figured it out after way too much time. I had renamed the sensor in my zwcfg file to “smokedetector”, and like yours used sensor.smokedetector_access_control when the binary sensor didn’t work. However, I noticed it that even though it shows up as “sensor.smokedetector_access_control” in the logbook events, when I went to the ‘States’ page under Developer Tools, it shows up as “sensor.ecolink_unknown_type0004_id0002_access_control.” Used that entity_id in my automations.yaml for the entity_id instead of the , and sure enough, it works.

Don’t know if this is a problem with Home Assistant or the sensor. Haven’t had that problem with other types of sensors.

Make a template sensor that displays open/close for the door:

  - platform: template
    sensors:
      main_door_hindge: # MAIN DOOR SENSOR #
        value_template: >
          {% if is_state('sensor.main_door_t_access_control_9_9', '23') %}
            closed
          {% elif is_state('sensor.main_door_t_access_control_9_9', '22') %}
            open
          {% else %}
            closed
          {% endif %}
        friendly_name: Main Door Status

then make an automation based on that, heres my automation & a 2 min timer scripts:

script 1:

alias: Foyer Door is Open
sequence:
  # Cancel ev. old timers
  - service: script.turn_off
    data:
      entity_id: script.foyer_light_timer
  - service: switch.turn_on
    data:
      entity_id: switch.foyer_s_switch_7_0
  # Set new timer
  - service: script.turn_on
    data:
      entity_id: script.foyer_light_timer

script 2

alias: Foyer Light Timer
sequence:
  - delay:
      minutes: 2
  - service: switch.turn_off
    data:
      entity_id: switch.foyer_s_switch_7_0

and automation

- alias: Foyer light trigger on main door 
  trigger:
    - platform: state
      entity_id: sensor.main_door_hindge
      to: 'open'
  condition:
    - condition: state
      entity_id: sun.sun
      state: "below_horizon"
  action:
    - service: homeassistant.turn_on
      entity_id: script.foyer_door_is_open

Also, I’m pretty sure your trigger isn’t triggering because you are using ‘above: 23’ and ‘below: 22’

above 23 never resolves to true because the sensor is actually outputting 23. above does not mean ‘greater than or equal to’, it means ‘greater than’. Same goes for below 22.