Hi all, I’m sure this will have been asked before, but I can’t find anything recent that’s applicable to Edge. Apologies if it has been discussed recently!
I have a Fibaro module behind a standard (non momentary) light switch. This controls lights in the porch. I have a Fibaro motion detector in the porch area. I’m using Mariano’s drivers for both.
I have been using Sharptools.io to manage a routine, but I would like to move it to native ST and keep it local.
I am trying to achieve the following, but I’m struggling with a bit of the logic, mostly around wanting to keep the lights on if I switch them on in the app. This seems to be the difficult bit.
- If motion at night turn on lights (if off)
- If lights physically switched on during motion countdown, stay on
- If lights physically switched on outside of motion, don’t trigger countdown to turn off
- If lights switched on in app when no motion, don’t trigger countdown to turn off
- If away and enter area at night, turn lights on and require them to be turned off after 5 minutes (don’t trigger countdown to turn off if motion as this is shorter) - I’ve not done this bit yet.
I have achieved the first 3 by using two virtual switches
- Switched VS, turn on / off when physical switch ‘pressed’ on ‘Main button’.
- Motion VS.
The ‘problem’ is that when the lights are switched on in the app, I can’t see a way of detecting this without using a virtual switch instead, which gets even more messy. If I use a routine to match the lights being turned on with the ‘switched VS’ then this is also triggered when the motion turns the lights on, meaning they don’t switch off as the ‘override’ is triggered by it. I can detect a physical switch press but not an app tile switch press.
Is this even possible without using a virtual light tile if I want to turn the lights on (and keep them on, so the motion doesn’t turn them off) from the app? I can see the need for 8 routines and 3-4 virtual switches for everything I want to achieve, which seems like an awful lot to maintain. Particularly as I want to replicate it for the garden!
Routines:
-
Porch Motion VS - turn on.
Preconditions: If between sunset / sunrise AND If lights off
When condition - motion is detected
Then do: Turn on Motion VS
-
Porch Motion VS Off
Precondition: Motion VS is on
When condition - motion is not detected for 10 seconds
Then do: Turn off Motion VS
-
Porch Switch VS On/off
If: Physical switch pressed
Then: Then Porch Switch VS of or off
-
Porch Lights turn off after motion
If: Motion VS switches off
Then: Turn lights off
Do you actually need to differentiate between using the physical switch and the app? Aren’t they essentially both ‘manual’ control?
I was thinking you might just need a ‘motion VS’ to flag that the light is under the control of the motion sensor.
The ‘motion VS’ should only be turned on when motion turns the light on, and it should be turned off if the physical button is pressed or the light reports being turned off.
My uncertainty is over exactly how the module behaves.
Hmm, I don’t really care if it’s physically or app switched, it’s more how to tell if the output is on because of app or routine.
I guess the complexity is that the light might be under motion sensor control but then be changed to manual control during motion - ie once the timer has started, or motion continues. I can’t base a routine to decide if motion control begins if the light is already on, because motion might have turned that on in the first place. I can use a manually switched VS but only at the door, not in app. So again, I can’t use that to decide if motion control begins.
I was rather thinking that if the porch light was already on due to motion, the only manual control option available to you in the app would be to turn it off.
With regard to the module, I assumed that the porch light was being turned on or off locally by the module with the ‘pressed’ event also being sent out to SmartThings so you could do other stuff. I wasn’t clear whether you could ‘turn on’ the light when it was already on.
So I was thinking about routines like:
if
porch light is off (precondition)
and
motion control virtual switch is off (precondition)
and
motion sensor is active
then
turn porch light on
turn motion control virtual switch on
if
button is pressed
or
porch light is off
then
turn motion control virtual switch off
if
motion control virtual switch is on (precondition)
and
motion sensor is inactive for a period of time
then
turn porch light off
So I have achieved this, but I don’t know it’s particularly efficient. It seems to work fine in testing.
Between sunset and sunrise… Outside of this time, the physical / app switching works as normal. Motion isn’t detected above 200 LUX AND outside of 15 minutes before sunset and 15 minutes after sunrise.
-
If motion detected and lights off, switch on for 10 seconds. If motion continues, lights stay on until 10 seconds after motion no longer detected.
-
If motion switches lights on and physical button pressed by the door, lights stay on until switched off in app or physically. Further motion events have no effect until lights are switched off manually.
-
If lights are switched on physically, motion events have no effect until the lights are switched off. The Motion VS will toggle, but not do anything.
-
If lights are switched on via the app, motion events have no effect until the lights are switched off. The Motion VS will toggle, but not do anything.
The Switched VS will toggle on/off if the power is switched on/off via the app or physically (or a mixture of). This was the hardest part!
Effectively this means:
- Automatic switching on / off via motion after dark
- Allows for manual ‘stay on’ override during a motion triggered event (physical button only, but that makes sense)
- Allows for manual ‘switch on’ both physically or in-app and motion detection won’t switch it off if triggered.
If anyone can help improve this, please let me know. Hopefully it’ll behave itself now it’s ‘live’. I occasionally saw the Switched VS triggered via motion, but I think that’s sorted now.
This is a lot of routines to achieve something seemingly fairly ‘simple’ but I guess this is a shortcoming of ST’s behaviour. I wanted to make this completely local without using third party tools either in the LAN or online.
Hope this helps anyone stumble across this thread!
Now to add in an extra layer of complexity… A routine to turn the lights on for a few minutes if one of us is coming home after dark.
1 Like