Mode based motion lightning help


#1

Hi Everyone,

Hope you are all good? Im having some strange things happen when using my Philips Hue lights in combination with Xiamoi motion sensors. Things like, I walk into the room and the lights come on then turn off after 2 secs, then another time it will work as expected, come on and turn off is no motion is detected. Im not sure if this is due to an error in the piston logic or something on the devices.

I use the following modes, just as reference.

($time24 < time0 ? ‘Sleep’ : ($time24 < time1 ? ‘Home - Dawn’ : ($time24 < time2 ? ‘Home - Morning’ : ($time24 < time3 ? ‘Home - Afternoon’ : ($time24 < time4 ? ‘Home - Bathtime’ : ($time24 < time5 ? ‘Home - Evening’ : ($time24 < time6 ? ‘Home - Night’ : ‘Sleep’)))))))

($time24 < time0 ? ‘Sleep’ : ($time24 < time1 ? ‘Away - Dawn’ : ($time24 < time2 ? ‘Away - Morning’ : ($time24 < time3 ? ‘Away - Afternoon’ : ($time24 < time4 ? ‘Away - Bathtime’ : ($time24 < time5 ? ‘Away - Evening’ : ($time24 < time6 ? ‘Away - Night’ : ‘Sleep’)))))))

Below is the piston:

Thanks
Neil


#2

I’ve noticed a couple of things (I am very new to WebCore FYI)

1 - When you say “if any of INACTIVE” (sensors ussualy stay active 15-20 second) as soon as it reads no motion it will trigger the piston.And if it registers inactive and you move around in the room again, the piston STILL BE TRIGGERED. It won’t go back and say “hold on hold on, he is still in the room, don’t turn my lights off”
2 - Technically your logic makes sense (Wait X minutes and then do this do that) but it was also my experience that it fails. (Pro WebCore coders would explain this one better)

The logic I found very reliable is this;

IF
ALL OF x, y, z sensor STAYS INACTIVE xx amount of time.
Turn OFF the bulbs.

ALL OF is very important.
Lets say you walked into a room that has 3 motion detectors. One at the door and two inside.
Once you pass the door sensor might not see you anymore BUT since it’s “one of the ANY,” it will trigger the piston as “Hey i am not active, lets turn these lights OFF”

But when you say ALL OF, then all the sensors must be inactive, so 99% that means you are a sleep LOL or no one is in the room. No blind spots.

Hopefuly this would explain the sudden turn off situation.

When you turn on the lights go with ANY OF THE SENSORS.
When you turn of the lights go with ALL OF THE SENSORS.

Here is one of my pistons for lights control and it works perfectly.


#3

Well put Ike, and a great example!
I don’t think you can call yourself “new to webCoRE” any more… :sunglasses:


#4

LOL thank you so much @WCmore
you have been a great help thats why…


#5

Thanks for this dude. How would I incorporate the day modes with this without screwing it all up! :slight_smile:


#6

Right under the line:
IF Motion changes to active
click on:
Add a new condition > Add a condition > Virtual Device > Location Mode > Select a comparison > is any of

temp


#7

And if the modes I wanted different light temps/brightness I can do that?

Like night - 1% level vs morning 75% and a different temp for example…

Thanks dude


#8

Most definitely. Post what you currently have so our reply is relevant.


#9

Will do. Im just looking how to build the example above…Trying to work out the first if “is equal to 1”… Hold the line :slight_smile:


#10

Oh, you can ignore that line in Ike’s example. He added an extra block at a later time to prevent the piston from running


#11

Here is his relevant code that is great as a foundation to build upon


#12

This is what I have so far… So I wanted to add a different motion active for both Home-Night, Home-Sleep and Home-Morning… Currently just the brightness, but might extend this to the temp too… Will I just add an if at the bottom to the first motion active command?


#13

Looks decent, but I have two observations:

(1) You can delete the Turn On line since setting a level does that automatically
(2) Line 30 should say IF ALL ___ stays inactive for 5 mins (instead of ANY)

This second tip is important to assure that you are out of the room, instead of just out of line of sight with one of the devices


#14

And yes, you can copy lines 17-28 if you want different levels during other location modes. Just make sure there are no overlaps