MvGrd
(Mark)
February 23, 2023, 3:12pm
1
I am trying so hard. Spinning my wheels on this simple automation. I’m trying to avoid the blueprint version in an effort to better understand YAML. It works just fine for me without the wait for trigger. I cannot get it to wait and then shut off. I know I’m missing something here an hoping that an answer will give me the kick start I need to getting to all the HomeAssistant goodness. Sincere thanks in advance.
- id: '1676993059605'
alias: TEST ON WITH MOTION
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 90
action:
- service: light.turn_on
data: {}
target:
entity_id: light.end_table
#mode: single
###############################
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: on
to: off
- delay: 10
# hours: 0
# minutes: 0
# seconds: 10
- service: light.turn_off
target:
entity_id: light.end_table
mode: single
123
(Taras)
February 23, 2023, 3:20pm
2
wait_for_trigger
's State Trigger needs to be indented.
Example
- id: '1676993059605'
alias: TEST ON WITH MOTION
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 90
action:
- service: light.turn_on
data: {}
target:
entity_id: light.end_table
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'on'
to: 'off'
- delay: 10
- service: light.turn_off
target:
entity_id: light.end_table
mode: single
1 Like
MvGrd
(Mark)
February 23, 2023, 3:23pm
3
Still does not work
- id: '1676993059605'
alias: TEST ON WITH MOTION
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 90
action:
- service: light.turn_on
data: {}
target:
entity_id: light.end_table
#mode: single
###############################
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: on
to: off
- delay: 10
# hours: 0
# minutes: 0
# seconds: 10
- service: light.turn_off
target:
entity_id: light.end_table
mode: single
# max_exceeded: silent
# mode: restart
Tinkerer
(aka DubhAd on GitHub)
February 23, 2023, 3:28pm
4
You didn’t indent it properly.
Look at the example given:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'on'
to: 'off'
now look at yours:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: on
to: off
123
(Taras)
February 23, 2023, 3:29pm
5
MvGrd:
Still does not work
Which part?
The part you didn’t copy correctly from my example?
MvGrd
(Mark)
February 23, 2023, 3:37pm
6
What I have now. Still does not work.
- id: '1676993059605'
alias: TEST ON WITH MOTION
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 90
action:
- service: light.turn_on
data: {}
target:
entity_id: light.end_table
#mode: single
###############################
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: on
to: off
- delay: 10
# hours: 0
# minutes: 0
# seconds: 10
- service: light.turn_off
target:
entity_id: light.end_table
mode: single
# max_exceeded: silent
# mode: restart
finity
February 23, 2023, 3:47pm
7
your indentation is still off:
yours:
action:
- service: light.turn_on
data: {}
target:
entity_id: light.end_table
#mode: single
###############################
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: on
to: off
- delay: 10
# hours: 0
# minutes: 0
# seconds: 10
- service: light.turn_off
target:
entity_id: light.end_table
what it should be:
action:
- service: light.turn_on
data: {}
target:
entity_id: light.end_table
#mode: single
###############################
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: on
to: off
- delay: 10
- service: light.turn_off
target:
entity_id: light.end_table
123
(Taras)
February 23, 2023, 4:03pm
8
MvGrd:
Still does not work
Still not indented correctly.
I respectfully suggest you consider using the Automation Editor, in Visual mode, because manually composing YAML isn’t working out for you.
1 Like
MvGrd
(Mark)
February 23, 2023, 4:05pm
9
This now gets the light turned on but it never turns off.
- id: '1676993059605'
alias: TEST ON WITH MOTION
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 90
action:
- service: light.turn_on
data: {}
target:
entity_id: light.end_table
#mode: single
###############################
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'on'
to: 'off'
- delay: 10
- service: light.turn_off
target:
entity_id: light.end_table
mode: single
finity
February 23, 2023, 4:11pm
10
are you sure the follwing is actually happening?
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'on'
to: 'off'
MvGrd
(Mark)
February 23, 2023, 4:14pm
11
How would I check that. Please bear with me…
MvGrd
(Mark)
February 23, 2023, 4:17pm
12
The logbook shows the motion event fires, the lamp turns on.
Tinkerer
(aka DubhAd on GitHub)
February 23, 2023, 4:21pm
13
Look at the entity in states and confirm it turns off
You can also (and should also) be checking the automation’s trace
MvGrd
(Mark)
February 23, 2023, 4:25pm
14
Ok, I think it is working. If I change the state of the motion detector from off to on, the lamp lights. If I then change the motion detector state from on to off, the lamp goes out. I am doing this remotely(not in the house). How do I mimick the way the motion detector would see motion and then not see motion. I mean mimick the way it would work were I in the house? Or am I doing that? Thank You!
Tinkerer
(aka DubhAd on GitHub)
February 23, 2023, 4:38pm
15
That is what you’re doing. All you need to do now is confirm that the motion sensor itself changes state correctly.
MvGrd
(Mark)
February 23, 2023, 4:54pm
16
How would I test the motion sensor itself remotely? I mean after changing its state from off to on, how could I watch it’s state change back to off to be sure it is doing what it should be doing? Hope that makes sense.
Tinkerer
(aka DubhAd on GitHub)
February 23, 2023, 5:43pm
17
Well, you need somebody to walk past the sensor.
If you manually change HA’s perception of the state the sensor isn’t going to know you’ve done that. Nothing really changed, so it’s not going to tell HA that it’s stopped detecting motion…
123
(Taras)
February 23, 2023, 5:55pm
18
If you’re interested, your automation can be reduced to this:
- id: '1676993059605'
alias: TEST ON WITH MOTION
description: ''
trigger:
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'off'
to: 'on'
- platform: state
entity_id: binary_sensor.z_wave_motion_sensor_motion_detection_2
from: 'on'
to: 'off'
for:
seconds: 10
condition:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 90
action:
- service: "light.turn_{{ trigger.to_state.state }}"
target:
entity_id: light.end_table
mode: single
1 Like
MvGrd
(Mark)
February 23, 2023, 6:54pm
19
Thank You so very much! I am so loving this software. HA is amazing and this community is great!
2 Likes