I have a Xiaomi Gateway with a window/door sensor. The sensor is on my front door, and I am attempting to trigger a light to go on when the door is opened, but only if the light level is below a certain value (using another Xiaomi sensor) and only if the sensor has not been activated for several minutes (to eliminate cases when I’ve closed the door and reopened it shortly afterwards).
The YAML I currently have looks like this:
- id: front_door_open
alias: Turn on living room light when front door opens at night
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d000149abe5
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: sensor.illumination_286c07891c0c
below: 75
- condition: state
entity_id: light.living_room
state: 'off'
- condition: state
entity_id: binary_sensor.door_window_sensor_158d000149abe5
to: 'off'
for:
minutes: 3
action:
service: light.turn_on
data:
brightness: 254
entity_id: light.living_room
This was working until I added the condition that the sensor hadn’t been activated for 3 minutes:
- condition: state
entity_id: binary_sensor.door_window_sensor_158d000149abe5
to: 'off'
for:
minutes: 3
When I add this, I get the following when checking the config:
Invalid config for [automation]: extra keys not allowed @ data['condition'][2]['for']. Got None
extra keys not allowed @ data['condition'][2]['to']. Got None
not a valid value for dictionary value @ data['condition'][2]['condition']. Got None. (See /config/configuration.yaml, line 256). Please check the docs at https://home-assistant.io/components/automation/
I suspect this is due to using the same sensor as the trigger and as a condition. Is this the case? How can I achieve what I’m trying to do here?
I’ve searched around and have not found an answer, but may be searching for the wrong thing.
Thanks