Now I’m sure this should be simple but I’ve got a complete block on this.
I have a motion sensor on my stairs which I’d like to turn the light on if it’s off and off if it’s on. This should be simple but of course creating two scences causes them to both trigger at the same time which does not have the desired effect.
I’m assuming that I should create a scene that is set to turn the light on when motion is detected.
The create another scene that will turn the light off it motion is detected but only run if the light is already on…this would be done using some code, does that sound correct ?.
I was thinking I might be able to do this with PLEG if that was easier than learning some LUUP but did not seem to get anywhere with it.
I’m sure it’s things like this that will be much easier for “consumers” once apple hit the HA world. It’s a seemingly simple issue but one that I can’t appear to crack.
Kind of weird you would turn off the light when there is motion there. Did u post in PLEG section this us very easy but has issues as the motion when kicks in with stay on for a few seconds. This is going to kick light on but motion is still active and now light is on and it’s going to want to kick the light right back off. This is going to happen fast and keep going until no motion. To fix that we will add an order it has to happen. If it sees motion before the light is on turn it off. But don’t turn it off if motion was after light on.
Inputs:
ILighton
Imotion
Conditions:
CLighton: Imotion and !ILighton and (Imotion; !ILighton)
CLightoff: Imotion and ILighton and (ILighton; Imotion)
You could place the code below in your scene Luup tab. The scene should be triggered by the motion sensor trip and have no device actions selected. The code checks the state of the switch and sets it to the opposite state.
local dID = 123 -- Device ID of your Z-Wave Switch
local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",dID)
if status == "1" then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{newTargetValue=0},dID)
else
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{newTargetValue=1},dID)
end
[quote=“mzpost, post:3, topic:183088”]Having one sensor at the bottom of the stairs my logic is this.
When it sees motion if the light is off then turn on the light (i.e. someone is going up the stairs).
Once the person comes back down the stairs then the motion sensors see’s them again and can turn the light off behind them.
I should add It’s a Fibaro motion sensor so I’ve set it to ignore any futher inputs for 15 seconds after the initial trigger.[/quote]
You need more then one motion and there is a smart switch plugin that works with motions and switches. But your logic on the “motion on motion again off” leaves something to be desired. Maybe after no motion for a bit just turn off the lights rather then motion again at bottom of stairs turn back off. But your probley going to need two motions for this to work right. As it is right now you need to manually turn on lights at top of stairs right? Then when it sees motion you want them to turn off. Does this happen mid stairs?
Sounds like motion at bottom should kick light on no motion and 1 min. later kick lights off. Coming down manually turn on as you are now. When no motion and 1 min after turn lights off. If you had motion on top would be same as bottom auto on 1 min. later turn off.
[quote=“RexBeckett, post:4, topic:183088”]You could place the code below in your scene Luup tab. The scene should be triggered by the motion sensor trip and have no device actions selected. The code checks the state of the switch and sets it to the opposite state.
local dID = 123 -- Device ID of your Z-Wave Switch
local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",dID)
if status == "1" then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{newTargetValue=0},dID)
else
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{newTargetValue=1},dID)
end[/quote]
This could also be done without LUUP (if you don’t understand it) by going to your scenes clicking advanced and selecting your device, add, then 2nd drop down select toggle state.
As long as you don’t trip the motion twice in one walk threw should work ok.
Best Home Automation shopping experience. Shop at Ezlo!