Hello,
I am new to Home Assistant. I have created a few automations and they are working well. However I am having trouble writing a slightly more complex automation where I have a z-wave motion sensor trigger a z-wave receptacle to turn ON and a timer event to start. When the timer event finishes, I want it to trigger the z-wave receptacle off. It works as far as triggering the timer event to start running.
I am having trouble with the yaml for the timer finish routine to trigger the switch to the off position.
Iâve looked through the docs and canât find any obvious errors in the yaml, but I canât save it as it complains of some error in the yaml. I looked for the schema and I couldnât spot the issue yet.
Can you copy-n-paste it, or tell us what steps you are taking or what screen you are on?
What documentation are you following?
[Any code and logs to be formatted nicely with </> so it is readable please.]
Are you using the UI or YAML? If you are using YAML, then you need an id: key. id: "this_is_my_automation"
The UI automatically generates a unique id for you.
Warning, if you make your automations in YAML they should be in a separate directory. In my configuration.yaml:
automation: !include gui/automations.yaml # this is only for GUI-Automations, do not touch this file!
automation manual: !include_dir_merge_list manual_automations/
Then put your YAML-generated automations into the config/manual_automations directory. In my case I have a file for each category. For example, all of my automations related to the garage are in config/manual_automations/garage.yaml
Last warning- the unique ID must be unique. When you restart or reload Home Assistant, you will get no warnings or errors if you have a duplicate id: key.
For a new user in 2026 that should really look like this, thereâs almost zero references left in the docs to âplatformâ or âservicesâ.
id: five_minute_motion_lght
alias: Turn on switch light for 5 min. on motion
description: Turns on switch on motion, turns off 5 minutes after motion stops
mode: restart
triggers:
- trigger: state
entity_id: binary_sensor.motion_sensor
to: "on"
actions:
- action: switch.turn_on
target:
entity_id: switch.your_switch
- wait_for_trigger:
- trigger: state
entity_id: binary_sensor.motion_sensor
to: "off"
for: "00:05:00"
- action: switch.turn_off
target:
entity_id: switch.your_switch
I am trying to understand a nuance. The wait_for_trigger section waits for either âoffâ of the sensor or for 5 minutes. Since, it is assumed, that the âoffâ is never coming, there is a 5 minute delay. Subsequently, in the action: switch.turn_off the switch is turned off (or off, again, if an âoffâ did arrive).
The assumption made is that the sensor does not send an âoffâ. I only have a few motion sensors and they send a âclearâ when the internal timeout is reached.
Is it true that âONâ, ON, âonâ, on, 1, â1â, âmotion detectedâ, etc.(or âOFFâ, OFF, âoffâ, off, 0, â0â, âclearâ, etc.) are not treated the same in condition statements?
The wait_for_trigger behaves like any other trigger, in this case it will wait for the binary_sensor to be in an off state for 5 minutes before firing and executing the following action.
Apparent states like âOnâ, â1â, âmotion detectedâ, âopenâ, âTrueâ âOffâ, â0â, âclearâ, âclosedâ, âFalseâ are front end formated results based on the entities device_class attribute. A binary sensor itself can only have a state of âonâ, âoffâ, âunknownâ, and âunavailableâ. You can always see an entities actual state in the Dev tools>States table.