Improve motion light piston to consider physical interaction


#1

1) Give a description of the problem
I have the piston below which works perfectly fine to turn my light on and off based on motion. I would now like to improve this piston to consider physical interaction with the switch as part of it’s logic. I have found another thread on here which describes how to add this logic but that is based on a dumb switch and smart bulb whereas in my case the bulbs are dumb and I have a Fibaro dimmer module installed behind the physical switch to achieve the smarts.

TIA!

2) What is the expected behavior?
If I turn the light on using the physical switch, the motion logic should “suspend” and the light should stay on until I use the physical switch to turn it off. Once it has been turned off, the motion logic should kick back into action

3) What is happening/not happening?
Piston is entirely motion based at the moment

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS)


#2

Just a thought,

IF
((time is between X and Y) AND (location mode is any of A and B))
AND
((motion sensor 2 motion is active) OR (switch 1 is on))
THEN


#3

I’n my experience, testing for the “physical interaction” with a smart switch does not produce reliable results.

So…you might have to do something where you actually turn the light off from the switch and then turn it back on again.

Then you can cancel the motion event if the light turns on.

I believe there is a piston created in the example section which shows this being done.


#4

I think I’d have to turn the light off and then back on again anyway because thinking about this last night, I realised that the motion sensor would be triggered in the process of entering the room and trying to switch the light off from the switch. So now as the light has been turned on by motion, I’d need to switch it off from the physical switch then back on again.


#5

See this thread…


#6

What I can’t figure out with the examples in that thread is that they are checking for the state of the physical switch as part of the logic but in my case, it could be that the light is on when the physical switch is in either the on or off position and also the light could be off with the physical switch in the on or off position. That is because I have toggle switches controlling dimmable lights so to dim up and down I do a single press of the toggle and to turn on and off I do a double press of the toggle. So checking for the status of the switch wouldn’t be of any use…

What I want is that if the light is on (assuming the motion sensing has turned it on when I go into the room) and I then switch it off using the physical switch and then back on again with the switch, it should stay on until I use the physical switch to turn it off. Once off, it should revert to the motion logic.


#7

I would think this version would work… But I guess my question would be, what happens in your case if the Physical switch is OFF and the motion turns on the light, and then you use the Physical switch and put it in the ON position? Does a z-wave signal get sent? Does the light stay ON?


#8

In this case, if I simply toggled the physical switch once to move it from the OFF position to ON position the light will stay on. The Fibaro dimmer modules interpret a single toggle to mean increase or decrease of dimming brightness so that’s what would happen.

I can try your suggested piston tonight unless my answer above changes it in some way…?


#9

@bangali wondering if you can help with this? I’m trying to use the 2nd version of your originally posted piston from the other thread which is for dumb bulbs and smart switches. The added nuance of my scenario is that I’m using toggle switches to control dimmable lights which may or may not affect how the piston needs to be coded. I’ve got the below so far, which is based on your piston but I don’t get the second if condition:

“If motion changes to inactive and {programmatic} is true, then turn off the light” - isn’t that the opposite of what we want? If programmatic is true then the light has been switched on manually so when the motion changes to inactive we want the light to stay on, not be turned off.


#10

programmatic is true when viamotion is true and viamotion is true when light was switched on by motion.

might need to delete line 48 and add a line after 65 to set programmatic to false.


#11

So what exactly are you using the programmatic variable for? Is it not to indicate when the light has been switched on physically as opposed to via motion? Sorry, I’m not able to follow the logic at the moment…


#12

i took another look at that piston and cant remember what problem i was solving at that time.

may be take out programmatic all together and just use viamotion and see if you run in to any issues?


#13

Hmm OK. I started changing the piston but as I’m attempting it I keep thinking I need to rewrite the piston with the following if conditions:

If motion sensor changes to active AND light is off
then turn on the light and set viamotion = true

If the light switch changes to on as a result of physical interaction
then set viamotion = false

If motion sensor changes to inactive AND light is on AND viamotion is false
then do nothing (i.e. light stays on)

If motion sensor changes to inactive AND light is on AND viamotion is true
then turn off the light

Shouldn’t this work? Any reason you could see why not? I’ll try it but just wanting your view. On that second IF condition about physical interaction, when I select my light in an if condition webcore gives me the option to select ‘Which interaction’ and I can choose ‘Any’, ‘Physical’ or ‘Programmatic’ so I’m assuming the ‘Physical’ one checks to see if the light was turned on at the switch so I can use that…?


#14

does your switch support physical interaction notification?


#15

Hmm, I don’t think it does. I’m using the ‘Fibaro Dimmer 2’ DTH written by Rajiv, Elnar Hajiyev and it doesn’t look like that DTH supports notification of physical interaction. Looking around the forum there may be a way to do it using Scene IDs but I’ll need to do more digging…alas, nothing is ever simple :slight_smile: