Using alexa to modify piston function, stop PIR controlling light


#1

I currently have a piston to do the following,
After sunset, if motion in room turn on light, when no motion turn off light.

I would like to modify it so when i ask alexa to turn on light, light to stay on till i ask alexa, or turn off light switch (Z wave button).

I’m not sure where to start and what functions to use when receiving this information from alexa etc.

Thanks all in advance.


#2

I might add, my PIR’s have a default of 3 minute wait time before a re-trigger is sent.
So i might have to disable this to a shorter period then use a timer or wait function in webcore.

Any thoughts is there a better way?

Thanks


#3

There are several different ways to accomplish this. I don’t know if my way is the most elegant way of coding or shortest but I use this at home and it works.

if time is between this and that
and
if KITCHENSIM is OFF (I will explain this)
and
if motion detected
Do this do that
if motion stays inactive
do this do that

so this is very similar to your piston, I just added the simulated switch

Now create a Simulated switch in ST IDE and lets call that KITCHENSIM
And create an Alexa routine that turns ON and OFF the KITCHENSIM switch. not the lights.

So your piston continues…

IF KITCHENSIM switch changes to ON
and
time is betwenn this and that
Turn ON kitchen lights…

IF KITCHENSIM switch changes to OFF
turn OFF kitchen lights.

so basically if the sim switch is ON your piston will ignore motion detectors…
and changing that ON will trigger your lights…

How do we go back to motion detectors?
a - you can turn the KITCHENSIM OFF via voice
b - setup a timer
c - if no motion for a longer period of time…

AS i said I am sure there are better ways of doing this but this might be a good start.

You can also use variables if this piston or scene is effected by other pistons etc…

note : I just assumed you would know how to create a sim switch… If not pls drop a line, I’ll explain that.


#4

can you send me your code please so i can download and work of that?

Thanks


#5

I think before i make things complicated i’m going to try improve the current piston to work as I want it.

At the moment, after 3 mins, the PIR goes inactive for 1 mins before it can trigger another active signal and the lights will turn on again. The 1 mins inactive is set by my PIR which i can’t change. That’s my main problem as even with motion in the room the light was turn off for 1 min.

I think the following might help, please advise if not. The goal is to make sure lights don’t turn off after the 3 minutes.


#6

With this piston - I assume - what would happen is,

You enter the room
Lights turn ON (If Kitchensim is OFF)
You tell alexa turn off the lights (or zwave button)
Lights won’t turn OFF until 4 minutes no activity.

Plus,
Lets say alexa or zwave button turned the kitchensim ON
you left the room,
Light OFF after 4 minutes
BUT
Kitchensim remains ON
so next time you walk in, lights won’t turn ON
Because your condition IF KITCHENSIM is OFF is not available.


#7

give me a couple of minutes,
I’ll work on that piston so you can download and play with it.


#8

Here you can try this one…

Important ;
1 - There is no one way of doing pistons. Mine is just one of the ways
2 - The reason I don’t have ELSE is my example piston is unkown LOL… I just never used them thats all.
3 - I am not a coder. If someone else knows a simpler/better way of doing this please share, that would be great if I can learn to write better pistons.
4 - If I were you, I would disable kitchen PIRs app related settings. In my fairly new smart home experience, it’s better letting one source control things. I heavily depend on webcore. More stuff you add to your system, you might get confused what is controlling what.

let me know if you have any questions.


#9

I just noticed something in my piston…
if you told alexa while you are in the room or pushed a button,
a motion in the room might trigger the lights. So they turn OFF and ON again.
But they will turn OFF in 5 minutes.

if this is not okay, you can just add WAIT 1 minute before LINE# 55


#10

Testing it now, with activity in kitchen the lights seem to stay on not like before that they would turn off for a minute then back on with activity.
I set my pir to 1 mins re-trigger over the previous 3 minutes…

i did notice when i ask alexa to turn on kitchen lights, the lights turn on then off straight away, but some time later it doesn’t seen to happen. kitchen light turn on when asked like they should.
i’ll keep testing this.

I set an alexa routine up so when i ask alexa to turn on kitchen lights. it turns on lights & also turns on KITCHENSIM.

Is this correct?


#11

Wait i just see what i did wrong.

My physical switch and lights are actually the one thing. I’m using a z wave relay which is connected to the physical switch on the wall.
So i can physically switch the lights on and off with a button or software turn the lights on and off with the app.
Each hardware and software have control over the relay.

The device name ‘‘kitchen lights’’ is actually a relay to power the kitchen lights.


#12

This has been working great up until i just bought a new sonos one but stupidly enough it doesn’t support routines. so i cannot use the ‘‘Turn on kitchen lights’’ command as it calls up a routine to turn on Kitchensim.

Any other ways around this?