I have a Hue light in my laundry room and I recently added a PIR motion sensor to turn it on automatically when we enter the room through an HA automation. I was working in there fixing the dryer the other day and had to manually disable the automation so that it didn’t turn off on me. While the laundry room isn’t the best use case for this specifically, I’d like to implement this in other rooms as well. I had the thought that the ideal solution would be something like a 3-position slide switch with motion, on, and off states, but can’t find anything commercially available. I’ve found some panels with buttons (like this one) that I could label manually, but those won’t indicate the current state. This seems like a relatively common use case so I’m wondering what others out there are doing.
I assume that you currently have a standard mechanical wall switch which you just leave in the on position, allowing your automations to control the lighting?
That being the case, you could consider the Sonoff ZBMINIR2: ZHA: Advanced features of Sonoff ZBMINIR2.
This sits behind your existing wall switch and, with its decoupled mode, allows you to continue using the mechanical wall switch to turn the light on and off (note that this does not cut power to the Hue light). Your motion automation could contain a condition to check the state of the relay and if on not fire the motion timer to turn the light off. You then flick the switch on your way out of the room.
Hey, thanks for you suggestion. Maybe I wasn’t clear enough in my requirements. If I understand correctly, this would cover 2 of the 3 states - the motion and on states, but not the off. The use case for the off state is having it in a bedroom where you wouldn’t want motion to trigger the light on in the middle of the night.
Currently, I’m using a Lutron Aurora switch that sits over the mechanical switch, which I installed before adding the motion sensor, but the automation still runs regardless of pressing it. I’ve seen other blueprints and motion-specific lighting schemes that use a button press as an indicator to not run the motion automation, but I’m not sure how the automation would ever then get turned back on using just the button.
That’s easy, just add a time condition to the motion on trigger so that it only operates from dusk until your bedtime, for example. I would not have a motion sensor in a bedroom, but that’s just me.
You can use a Timer Helper for where motion or presence detection momentarily loses track of someone present in an area. That is used to set a time limit for when motion/presence isn’t detected before it shuts off. Automation wait times will not persist through a rebooting of HA, but Timer Helpers will (and I reboot HA often, while I learn and grow with this home automation experiment/hobby).
I also use Lutron Aurora rotary dimmers in a few of the locations where I also use motion or presence detectors - bear in mind I haven’t bothered (yet?) to add a routine to override motion/presence detection if the lights are manually turned on (just don’t have the need - yet ). That said, here’s the automation I use with a Timer Helper for my garage. . . if I’m under/behind something doing a repair, the lights will dim to let me know I have 4 minutes before the lights will time out.
alias: Garage Presence
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.motion_group_garage
to: "on"
id: garage-occupied
from: "off"
- trigger: state
entity_id:
- binary_sensor.motion_group_garage
to: "off"
id: garage-unoccupied
from: "on"
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.timer_garage_lights
id: timer-finished
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- garage-occupied
sequence:
- action: timer.cancel
data: {}
target:
entity_id: timer.timer_garage_lights
- action: light.turn_on
metadata: {}
data:
brightness_pct: 100
transition: 3
target:
entity_id: light.garage_lights_z2m
- conditions:
- condition: trigger
id:
- garage-unoccupied
sequence:
- action: light.turn_on
metadata: {}
target:
floor_id: basement
data:
brightness_pct: 75
- action: timer.start
target:
entity_id:
- timer.timer_garage_lights
data:
duration: "0:04:10"
- conditions:
- condition: trigger
id:
- timer-finished
sequence:
- action: light.turn_off
metadata: {}
data:
transition: 3
target:
entity_id: light.garage_lights_z2m
enabled: true
mode: single
Like most here, I just use a timer in the code to turn off after no motion for x minutes. I would hope your motion sensor sees you moving while you are in that room?
In this code, I have 2 motions sensors, one is a FP2, the other is a Aquara PIR. They are in the kitchen group of motion sensors.
I have this turn the light on for 7 mins, and stays on, if: motion is detected, and, if: its darker, and,: during certain times of the day (ie not the middle of the day, unless its cloudy enough to be dark). 2 diff sets of code here, as I don’t always use timers:
alias: Notimer Kitchen Light OFF 7 mins after motion
description: Notimer Kitchen Light OFF 7 mins after motion
triggers:
- trigger: state
entity_id: group.kitchenmotion
to: "off"
from: "on"
for:
hours: 0
minutes: 7
seconds: 0
conditions:
- condition: or
conditions:
- condition: time
after: "17:00:00"
- condition: sun
before: sunrise
actions:
- action: switch.turn_off
target:
entity_id: switch.kitchen_light
data: {}
mode: single
alias: Kitchen MotionGroup-light ON 9-16-2021
description: Kitchen MotionGroup-light ON 9-16-2021
triggers:
- trigger: state
entity_id: group.kitchenmotion
id: group.kitchenmotion
from: "off"
to: "on"
conditions:
- condition: or
conditions:
- condition: sun
after: sunset
after_offset: "-02:45:00"
- condition: sun
before: sunrise
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.presence_sensor_fp2_6166_light_sensor_light_level
below: 65
actions:
- action: switch.turn_on
data: {}
target:
entity_id: switch.kitchen_light
mode: single
Maybe not the prettiest code, but it seems to work well. Of course, any suggestions for cleanup are welcomed. ![]()
Use the wasp in a box template if you also have a door you can put a door sensor on, its the easiest solution to these types of setups.
I use a pressure mat connected to an aqara leak detector set to occupancy mode in HA, its setup so that when I am in bed for 30s my lights are turned off then it disables the motion automation’s and enables them when I am out of bed as well as a few other tasks based on if I am in bed or not for x time.
The motion sensor I have in the bedroom is at foot level so that it prevents false positives if I move about in bed when sleeping.
