Can’t get my automations.yaml file right to turn off motion lights in bathroom
#Motion Detected Light on BATHROOM
#- id:
alias: 2nd Bathroom Lamp On
trigger:
- platform: state
entity_id: switch.ge_26931_smart_motion_switch_switch_3 #<- This should be your motion sensor or binary_sensor
to: 'on'
for:
minutes: 2
#condition:
#- condition: time
# after: '20:00:00' # <- motion will only trigger the light on between these times
# before: '05:00:00'
action:
- service: switch.turn_on # or use homeassistant.turn_on
entity_id: switch.ge_26931_smart_motion_switch_switch_3 #light.your_light # <- this should be your light entity_id
# Motion Light OFF After 10 Min BATHROOM
#- id: switch.ge_26931_smart_motion_switch_switch_3
alias: 2nd Bathroom Lamp Off
trigger:
- platform: state
entity_id: switch.ge_26931_smart_motion_switch_switch_3 #<- This should be your motion sensor
to: 'off'
for:
minutes: 3
action:
- service: switch.turn_off #or light.turn_off
entity_id: switch.ge_26931_smart_motion_switch_switch_3 # or light.your_light # <- this should be your light entity_id
Yes it does. You need to start each automation with a hyphen. So the top of the first automation should be:
- alias: 2nd Bathroom Lamp On
…and the second:
- alias: 2nd Bathroom Lamp Off
Although, the automations as written are confusing. The first one says “if the switch is on for 2 minutes, turn the switch on” and the second one is saying “if the switch is off for 3 minutes, turn the switch off.”
Based on what I can see here, the trigger in both of those automations should be a motion sensor which is a binary_sensor.
The motion sensor you’re talking about would be a binary sensor. That’s what you want in the trigger. Right now you have the switch in both the trigger and action.
Do I just type “binary”?
It’s a light switch and motion all in 1. I have not found binary anything for this.
I have binary for another motion detector but it’s just a motion detector.
Could it be “sensor”.xxx?
#MOTION LIGHT ON on BATHROOM
#- id:
#- alias: 2nd BATHroom Light. This one TOO
#trigger:
#- platform: state
#- entity_id: sensor.ge_26931_smart_motion_switch_sourcenodeid_4 #<- This should be your motion sensor or binary_sensor
# to: 'on'
#for:
# minutes: 2
#condition:
#- condition: time
# after: '20:00:00' # <- motion will only trigger the light on between these times
# before: '05:00:00'
#action:
#- data:
# - service: switch.turn_on # or switch.turn_on # or use homeassistant.turn_on
#- entity_id: switch.ge_26931_smart_motion_switch_switch_4 #light.your_light # <- this should be your light entity_id
# MOTION LIGHT OFF After 10 Min BATHROOM
#- id: switch.ge_26931_smart_motion_switch_switch_3
- alias: 2nd BATHroom Light. This one TOO
trigger:
- platform: state
entity_id: sensor.ge_26931_smart_motion_switch_sourcenodeid_4 #<- This should be your motion sensor
to: 'off'
for:
minutes: 3
action:
- data:
- service: switch.turn_off #or light.turn_off
entity_id: switch.ge_26931_smart_motion_switch_switch_4 # or light.your_light # <- this should be your light entity_id
REGISTERED ENTITIES for switch_4 (There are a lot). I included ones next to if for visual.
- alias: 2nd BATHroom Light. This one TOO
trigger:
- platform: state
entity_id: sensor.ge_26931_smart_motion_switch_sourcenodeid_4 #<- This should be your motion sensor
to: 'off'
for:
minutes: 3
action:
- data:
- service: switch.turn_off #or light.turn_off
entity_id: switch.ge_26931_smart_motion_switch_switch_4 # or light.your_light # <- this should be your light entity_id
the “sourcenodeid” entity won’t ever change and isn’t the entity you need to look at to trigger the automation.
Since there isn’t a binary_sensor (unless there is and you just didn’t show it…) then you will probably need to end up using the “alarm_level” or the “burglar” sensors to trigger the automation. to do that you’ll need to see what the values of those sensors change to when you activate the motion sensor.
# MOTION LIGHT OFF After 10 Min BATHROOM
#- id: switch.ge_26931_smart_motion_switch_switch_3
- alias: 2nd BATHroom Light. This one TOO
trigger:
- platform: state
entity_id: sensor.ge_26931_smart_motion_switch_alarm_type_4 #<- This should be your motion sensor
to: 'off'
for:
minutes: 3
action:
- data:
- service: switch.turn_off #or light.turn_off
entity_id: switch.ge_26931_smart_motion_switch_switch_4 # or light.your_light # <- this should be your light entity_id
and
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Show the introduction message on startup.
introduction:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Discover some devices automatically
discovery:
# Sensors
sensor:
# Weather prediction
- platform: yr
- platform: random
# Motion
#- plateform: state
# Text to speech
tts:
- platform: google
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
Because that isn’t a “switch”. You can tell that by the fact that it starts with “zwave.xxx” and not “switch.xxx”.
That is the base zwave device itself. You can think of it like the “controller” or “brain” of the individual device that does all of the overhead that is needed for the other auxiliary functions to operate.