I have an automation running that turns on a light when motion is detected between certain hours and then off after 1 minute of no motion.
I need to do the same thing but with a switch
This works
alias: Family Room Late Night
description: ''
trigger:
- platform: state
entity_id: binary_sensor.family_room_motion
to: 'on'
- platform: state
entity_id: binary_sensor.family_room_motion
to: 'off'
for: '0:01:00'
condition:
- condition: time
after: '23:00:00'
before: '06:00:00'
action:
- service: 'light.turn_{{ trigger.to_state.state }}'
entity_id: light.family_room_right
mode: single
This does not work
alias: Master Bedroom Motion
description: ''
trigger:
- platform: state
entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
to: 'on'
- platform: state
entity_id: automation.master_bedroom_motion
to: 'off'
for: '00:02:00'
condition:
- condition: time
after: '09:30:00'
before: '22:00:00'
action:
- type: turn_on
device_id: 3462fefb095ea75ce9446f63a27e1f4c
entity_id: switch.bedroom_dresser_on_off
domain: switch
mode: single
ah… Good catch @anon43302295 , I missed that
This will turn the switch on but not off
I suspect the issue is the Action Service which I modified from the other automation but, I’m not sure how to fix it.
Unless there is a better way to do this
alias: Master Bedroom Motion
description: ''
trigger:
- platform: state
entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
to: 'on'
- platform: state
entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
to: 'off'
for: '00:02:00'
condition:
- condition: time
after: '09:30:00'
before: '22:00:00'
action:
- service: 'switch.turn_{{ trigger.to_state.state }}'
entity_id: switch.bedroom_dresser_on_off
mode: single