Use Motion Sensor as Toggle command with Lamp?

Hi… I want to use Motion Sensor to toggle my lamp on/off at night. I created a Virtual Switch that I connected with my lamp and later added the motion sensor security app to control the virtual switch but I can’t find how to use the motion sensor to switch off the lamp. My idea is that when motion Is detected , Sensor should send a state change command to virtual switch that will switch on/off the lamp. So one motion will switch on and other will switch off the lamp ! Is this possible?

Why use any virtual switches in your use case? I do something similar with the SmartLighting app to control lights on my stairs.

In my case whenever motion is detected it turns on the lights, and then turns them off after no motion has been detected. Is this similar to what you’re trying to do:

2 Likes

Thanks… but i don’t want to switch off the light after motion stops. Actually, i want to use motion detector to switch on the light when motion is detected and keep it On and later when i want to switch off the light, i will swipe my hand again over the detector to switch off the light. That’s why i thought having a virtual switch in between may help… But currently motion detector is only sending a Switch On command and not the Toggle /State change Command to my virtual switch so i can only Switch On light but not switch it off using the Motion Detector.

Usually I use voice commands with Google Home to control my lamps but I have a baby in my room and sending voice commands every 30 mins is really annoying so just wanted to have a motion sensor to do the trick instead…

if its a hassle, i may get a push switch instead …

I would do this using two Smart Lighting automations. The reason I would use Smart Lighting is because I don’t have a device capable of running the new app and so have never even seen the custom automation creator, let alone used it. I don’t have the app to hand to give a pretty picture but the options would be something like:

Turn Light On

Which devices do you want to control? - Your Light
What do you want to do? Turn on
Select trigger - Motion
Which motion sensors? - Your Motion Sensor
Turn on when - Motion Starts
Only if this switch - Your Light
Is - Off

Turn Light Off

Which devices do you want to control? - Your Light
What do you want to do? Turn off
Select trigger - Motion
Which motion sensors? - Your Motion Sensor
Turn on when - Motion Starts
Only if this switch - Your Light
Is - On

1 Like

Good suggestion… let me implement and get back… but the sequence of execution will matter as both are triggered by same motion :thinking:

You wouldn’t be the first to think that. I certainly did. However this is the same approach commonly used to make a button toggle lights in Smart Lighting (Smart Lighting’s toggle function doesn’t allow for switches changing state outside the automation) and it seems to work reliably. You will hopefully find yourself wondering why it works.

My thinking was that Smart Lighting automations probably update their ‘only if’ restrictions in response to events rather than doing a real time check. So it is only after running the motion event that they receive the event saying the light has changed state.

I implemented your given solution and viollla it works like a charm… I think the trick is checking the status of the lamp before running the routine :slight_smile:

Thanks again for your help … have a great day !