Well that’s unfortunate! I would think that’d be a main reason to get a motion sensor. I bought a couple and haven’t hooked them up yet. I really hope it doesn’t take minutes to turn the lights on, that would be idiotic.
Try to make a group to turn several switch on at once, it will be much faster than the sequence.
Also you should try to use timers to handle the turn off sequence, it will also allow you to keep the light on if there is still some movement.
Here it’s what it would look like:
automation:
- alias: Light hallway if motion 2
trigger:
- platform: state
entity_id: switch.net_hallsensor
to: 'on'
condition: state
entity_id: input_select.status_hallway
state: 'Hemma'
action:
- service: timer.start
entity_id: timer.timer_hallway
- service: switch.turn_on
entity_id: group.hallway_light
- alias: Turn off hallway lights at end of timer
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.timer_hallway
action:
service: switch.turn_off
entity_id: group.hallway_light
timer:
timer_hallway:
duration: '00:03:00'
group:
hallway_light:
name: "Hallway light"
entities:
- switch.hall_entre
- switch.hall_golvlampa
- switch.hall_kladhangare
That will turn them on for 3 minutes, and restart the 3 minutes delay every time a new movement is detected.
I use it with some 433MHz movement sensor and a DYI bridge (433MHz to mqtt), and that turn ON the light in about 1 second.
Also make sure the fibaro is setup correctly, per default the Fibaro only report movement after 2 detection (pulse counter).
Just for your reference, here is my turn on/off motion light in one automation.
automation kitchen_light_movement:
alias: Turn on off kitchen lights when there is movement
trigger:
- platform: state
entity_id: binary_sensor.Family_Room_Motion
to: 'on'
- platform: state
entity_id: binary_sensor.Family_Room_Motion
to: 'off'
for:
minutes: 10
action:
- service_template: '{% if trigger.to_state.state == "on" %}homeassistant.turn_on{% elif trigger.to_state.state == "off" %}homeassistant.turn_off{% endif %}'
entity_id: light.kitchen_light
@RobDYI thanks for the AIO method, ive been looking for a way to clean this up.
Question for you though, how do you handle turning off the lights if they were turned on by means other than motion.
If I understand the way the trigger works correctly, its only going to turn them off when the state of the motion sensor changes to off (for 10 mins). So if there is already no motion and the lights are turned on by a scene change, a grouped switch, or a meddling childs fingers, then the state will never change to off to trigger the automation, because it has been in off the whole time.
Thanks @dawnlord
So basically I need to create a fake switch for every switch/group tied to a motion automation?
Could I just use the light/switch/group state as a trigger?
Would I need to add a condition for motion=no to prevent conflicts with the normal timer? Or would setting it to a higher delay count than the normal timer do the trick.
So if this is my normal motion sensor on/off automation
alias: Turn on off family room lights when there is movement
trigger:
- platform: state
entity_id: binary_sensor.Family_Room_Motion
to: 'on'
- platform: state
entity_id: binary_sensor.Family_Room_Motion
to: 'off'
for:
minutes: 10
action:
- service_template: '{% if trigger.to_state.state == "on" %}homeassistant.turn_on{% elif trigger.to_state.state == "off" %}homeassistant.turn_off{% endif %}'
entity_id: group.family_room
I assume this would work as a failover without causing any conflicts
alias: Failover family room lights off
trigger:
- platform: state
entity_id: group.family_room
to: 'on'
for:
minutes: 15
condition: state
entity_id: binary_sensor.Family_Room_Motion
state: 'off'
action: homeassistant.turn_off
entity_id: group.family_room
Thanks for your script. I made it event shorter on the action section and it works
automation kitchen_light_movement:
alias: Turn on off kitchen lights when there is movement
trigger:
- platform: state
entity_id: binary_sensor.Family_Room_Motion
to: 'on'
- platform: state
entity_id: binary_sensor.Family_Room_Motion
to: 'off'
for:
minutes: 10
action:
- service_template: 'light.turn_{{trigger.to_state.state}}'
entity_id: light.kitchen_light