here’s my code when i used the GUI to set things up. what seems to be the problem?
alias: auto living room door light to on when motion or door is opened
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.besense_home_security_motion_detection
to: "on"
condition: []
action:
- service: light.turn_on
target:
entity_id: light.light_living_room
data:
brightness_pct: 100
- wait_for_trigger:
- platform: state
entity_id:
- binary_sensor.door_living_room_contact
- binary_sensor.besense_home_security_motion_detection
to: "off"
for:
hours: 0
minutes: 10
seconds: 0
timeout:
hours: 0
minutes: 0
seconds: 0
milliseconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.light_living_room
mode: single
Your timeout could be a problem. Since it is at 0, it would go right past the ‘wait for trigger’ and move to the off action. So your light would be turning on and then immediately turning off. Looking at the history of the light will give you a better clue.
final question please. will this turn off the light when both triggers are OFF or only 1 trigger?
i want to have them both to be OFF for the light to turn off.
- wait_for_trigger:
- platform: state
entity_id:
- binary_sensor.door_living_room_contact
- binary_sensor.besense_home_security_motion_detection
to: "off"
If you are not familiar with YAML, then a more simple implementation will be to make 2 conditions checking they are “off”. Conditions are “AND”. Can easily be made in the GUI.
Also, you don’t see a field for: in the automation editor after selecting template as trigger platform. If you want use this, create a group and set it to all: true.
all - boolean (optional, default: false) Only available for binary_sensor, light and switch groups. Set this to true if the group state should only turn on if all grouped entities are on. https://www.home-assistant.io/integrations/group/#all
This way you can use platform: state as trigger platform in combination with for:
However (also with regard to any wait_for_trigger), please note that the for option will not survive a HA restart or reload of that automation. To avoid that, use a helper (e.g. input_number) and alter the for: field like that: