Door contact automation not working

I have a Xiaomi door sensor and struggling to get it to trigger an automation.
What’s wrong here?
If I run the automation manually the light turns on so it must be the trigger.

- id: '1636824536443'
  alias: Turn on light when door opened
  description: ''
  trigger:
  - entity_id: binary_sensor.doorsensor2_contact
    platform: state
    attribute: contact
    to: 'on'
  condition: []
  action:
  - type: turn_on
    device_id: 279a1e9f8293ebb4fc4b5d3d8df360a5
    entity_id: light.shelly_shdm_2_e8db84d7873f
    domain: light
    brightness_pct: 100
  mode: single

Maybe try dropping the ‘attribute’ line from the trigger.

1 Like