Motion Based Light EXCEPT when Manually turned On

manual
except
off
light
motion

#121

you dont need to change switch in the piston … just use alexa to switch on dimmer 2.

add that to line 30 by using only when restriction.


#122

It wouldn’t let me change line 30, unless I’m doing it wrong of course (which is highly possible) so I changed it at line 21/22 as that was the only alternative that made sense.
I changed the dimmer switch to kitchen as it is a Tradfri bulb named “kitchen” not a switch/dimmer.
I won’t know until sunset if it works.
The motion parts works very well and I haven’t needed to turn on via Alexa since I installed the initial piston that you posted. Making a full English Breakfast last night, the light stayed on all the time from opening the bacon to dishing it up on two plates.
So as far as I’m concerned a fantastic job. Done by yourself.


#123

its fine. that will work too.

cool. dimmer, switch or bulb everything should work.


#124

Hi Newbie to WebCore here.

This looks interesting to me. Just wants to make sure that it works for me. I have a outside lamp which is controlled by motion from a Ring Door bell between sunset and sunrise. I also would like to turn on the bulb at 5 pm and turn off at 10 pm. During this time I dont want motion to affect the behaviour of the light and wants to remain on. At present I have a timer on smartlighting smart app for the lamp to come on at 5 and turn off at 10. But during this time if motion is detected the lamp turns off after 2 minutes.
Thanks


#125

I would suggest 2 different pistons for your situation. One to just turn the light on everyday from 5-10pm (or just keep using your smart lighting smartapp). Then use a motion based piston for anytime after 10pm until sunrise. The topic piston is for if you want to use motion based lighting, but be able to disengage if light is manually turned on.


#126

Thanks for replying. But if I use another piston or smartlighting smart app to keep the light on from 5-10 pm, is it not equivalent to manually turning it on?


#127

That depends on what switch and/or bulb you are using. What I’m saying is to have 2 separate smartapps or pistons, and set each to only work during those time periods so they do not interfere with each other. So on the smart lighting smartapp, configure it to only run from 5-10pm. Then for the motion based lighting, configure it to only run from 10:01pm to sunrise (or how ever long you want).


#128

I’ve tried this piston on a couple of lights and it’s working great.

As a noob, I’m trying to complicate it a bit…
In my scenario, a bulb is already lit X color, changes to Warm White on motion and then returns back to X once motion stops.

The piston shown sort of works, except that if motion is detected during the 1 minute inactive timer, the piston captures (and restores) Warm White instead of the original X color. Any suggestions?


#129

change the capture statement to prevent overwriting existing state to true and on the second restore statement empty state to true.


#130

Perfect! Thanks for the nudge, it got me wandering a little further down the rabbit hole. :slight_smile:


#131

This was great, thanks. My Daughter had just moaned at me that my new Hue lights outside her bedroom were a pain as they went off and then on again as I walked past and I could find an easy solution. Started looking at WebCore and this was the first example piston that jumped out, problem solved.

Thanks :smiley:


#132

Hey bangali,

Firstly, thank you so very much for all your help with this particular piston! You, among others, are most definitely an asset here and I appreciate all the effort in helping us get to an automated ST nirvana!

I have all LIFX bulbs and a smartthings motion detector that seem to work well. And, as odd as this may sound for a beginner in this area, I was able to do everything on my own by just digging around and reading (for only 8 hours for this one project LMAO)

My problem is that when I use a piston - any number of the ones included here, they react very slowly as compared to just giving alexa a command such as “alexa turn off the living room.” When I use this piston (4hjj8) with the lights set up as a virtual device (the 4 LIFX bulbs) they turn off over about 4-5 seconds one at a time. Is this normal? Seems so slow when compared to ST or Alexa based commands which I would think is odd.

For whats it is worth, I have included the piston for reference that I used as a template and then tweaked to suit my own setup. I do agree it is far easier if you use alexa as the manual switch especially if it is across the room from where you sit lol.

I have a feeling its something on my end because i have not seen anyone else mention this behavior. Any help would be most appreciated!


#133

you are welcome.

:+1:

it does take a 1 - 2 seconds but 4 -5 seconds seems odd.

have you tried checking the ST IDE logs and checking what is happening when you issue the command via alexa vs when the piston runs?


#134

This is what i get when I turn off switch 1:

64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:07 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:07 PM: debug Property Change Event switch: off (source: DEVICE)
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:13:07 PM: debug sending data to AT
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:13:07 PM: debug A sensor event occurred: [name:switch, deviceId:bd3b8dc0-7f71-435b-a7f4-d08231db3d4f, isoDate:2017-12-09T18:13:07.177Z, unit:null, value:off]
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: debug off()
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: trace stopAction()
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: trace ambientLightOK = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: trace timeOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: trace timeWindowStop = null
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: trace timeWindowStart = null
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: trace daysOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: trace modeOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:13:02 PM: trace stopHandler(switch: off)
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:07 PM: debug Body: [results:[[id:d073d521a8b9, status:ok, label:Den Lamp]]]
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:07 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:05 PM: debug Beginning API PUT: /lights/id:d073d521a8b9/state, [power:off]
bd3b8dc0-7f71-435b-a7f4-d08231db3d4f 1:13:05 PM: debug Device setOff
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:05 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:05 PM: debug Property Change Event switch: off (source: DEVICE)
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:13:05 PM: debug sending data to AT
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:13:05 PM: debug A sensor event occurred: [name:switch, deviceId:8c30f666-1d17-43c6-8437-b72a61e32f29, isoDate:2017-12-09T18:13:05.886Z, unit:null, value:off]
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:05 PM: debug Body: [results:[[id:d073d521ae66, status:ok, label:Den 3]]]
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:05 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:04 PM: debug Beginning API PUT: /lights/id:d073d521ae66/state, [power:off]
8c30f666-1d17-43c6-8437-b72a61e32f29 1:13:04 PM: debug Device setOff
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:04 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:04 PM: debug Property Change Event switch: off (source: DEVICE)
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:13:04 PM: debug sending data to AT
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:13:04 PM: debug A sensor event occurred: [name:switch, deviceId:aeddda60-c698-4641-ae24-8e8ae1d8ea2a, isoDate:2017-12-09T18:13:04.900Z, unit:null, value:off]
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:04 PM: debug Body: [results:[[id:d073d52012e3, status:ok, label:Den 2]]]
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:04 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:03 PM: debug Beginning API PUT: /lights/id:d073d52012e3/state, [power:off]
aeddda60-c698-4641-ae24-8e8ae1d8ea2a 1:13:03 PM: debug Device setOff
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:03 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:03 PM: debug Property Change Event switch: off (source: DEVICE)
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:13:03 PM: debug sending data to AT
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:13:03 PM: debug A sensor event occurred: [name:switch, deviceId:86b31e83-50fa-4a55-bfcb-7f678d92ae45, isoDate:2017-12-09T18:13:03.605Z, unit:null, value:off]
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:03 PM: debug Body: [results:[[id:d073d521ae12, status:ok, label:Den 1]]]
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:03 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 1:13:02 PM: debug Beginning API PUT: /lights/id:d073d521ae12/state, [power:off]
86b31e83-50fa-4a55-bfcb-7f678d92ae45 1:13:02 PM: debug Device setOff
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:02 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:02 PM: debug Property Change Event switch: off (source: DEVICE)
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:13:02 PM: debug Turn off Switch 1

The whole things takes about 5 seconds or so… Here is what I get when I turn on the virtual switch via Alexa. *Note: The time frame is the same whether or not I use alexa to invoke the command or the motion sensor.

64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:53 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:53 PM: debug Property Change Event switch: on (source: DEVICE)
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:18:53 PM: debug sending data to AT
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:18:53 PM: debug A sensor event occurred: [name:switch, deviceId:bd3b8dc0-7f71-435b-a7f4-d08231db3d4f, isoDate:2017-12-09T18:18:53.596Z, unit:null, value:on]
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: debug on()
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace ambientLightOK = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace timeOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace timeWindowStop = null
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace timeWindowStart = null
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace daysOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace modeOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace ambientLightOK = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace timeOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace timeWindowStop = null
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace timeWindowStart = null
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace daysOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace modeOk = true
fd3fa205-14ac-45e6-ad01-6f82e3d5fa16 1:18:48 PM: trace triggerHandler(switch: on)
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:53 PM: debug Body: [results:[[id:d073d521a8b9, status:ok, label:Den Lamp]]]
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:53 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:52 PM: debug Beginning API PUT: /lights/id:d073d521a8b9/state, [power:on]
bd3b8dc0-7f71-435b-a7f4-d08231db3d4f 1:18:52 PM: debug Device setOn
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:52 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:52 PM: debug Property Change Event switch: on (source: DEVICE)
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:18:52 PM: debug sending data to AT
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:18:52 PM: debug A sensor event occurred: [name:switch, deviceId:8c30f666-1d17-43c6-8437-b72a61e32f29, isoDate:2017-12-09T18:18:52.441Z, unit:null, value:on]
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:52 PM: debug Body: [results:[[id:d073d521ae66, status:ok, label:Den 3]]]
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:52 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:51 PM: debug Beginning API PUT: /lights/id:d073d521ae66/state, [power:on]
8c30f666-1d17-43c6-8437-b72a61e32f29 1:18:51 PM: debug Device setOn
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:51 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:51 PM: debug Property Change Event switch: on (source: DEVICE)
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:18:51 PM: debug sending data to AT
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:18:51 PM: debug A sensor event occurred: [name:switch, deviceId:aeddda60-c698-4641-ae24-8e8ae1d8ea2a, isoDate:2017-12-09T18:18:51.217Z, unit:null, value:on]
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:51 PM: debug Body: [results:[[id:d073d52012e3, status:ok, label:Den 2]]]
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:51 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:50 PM: debug Beginning API PUT: /lights/id:d073d52012e3/state, [power:on]
aeddda60-c698-4641-ae24-8e8ae1d8ea2a 1:18:50 PM: debug Device setOn
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:50 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:50 PM: debug Property Change Event switch: on (source: DEVICE)
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:18:50 PM: debug sending data to AT
f4b9edda-1134-403e-9cde-30b3fc3c8eef 1:18:50 PM: debug A sensor event occurred: [name:switch, deviceId:86b31e83-50fa-4a55-bfcb-7f678d92ae45, isoDate:2017-12-09T18:18:50.000Z, unit:null, value:on]
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:49 PM: debug Body: [results:[[id:d073d521ae12, status:ok, label:Den 1]]]
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:49 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 1:18:48 PM: debug Beginning API PUT: /lights/id:d073d521ae12/state, [power:on]
86b31e83-50fa-4a55-bfcb-7f678d92ae45 1:18:48 PM: debug Device setOn
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:48 PM: info postEventToEndpoint: event successfully posted.
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:48 PM: debug Property Change Event switch: on (source: DEVICE)
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:48 PM: debug Turn on Switch 1
64edeb58-9574-4f3f-b36e-b422e6b7818c 1:18:48 PM: debug handlePostV3
fcb65459-6d0b-4a12-a5ab-835565879958 1:18:48 PM: debug PUBLISHED on()

Hopefully this helps. It appears as if it is going through each light one by one. Surely there is a way to do them all at once? I dont know. Thanks for any help! :slight_smile:


#135

so when turning off via wC or alexa both are taking the same time to turn off and each is going thru and turning off bulbs one by one?

i may have gotten something wrong.


#136

What is wC?

Yes the time it takes to turn off/on the lights once the piston starts is the same. In other words, the voice activation through echo or the motion detection through the motion detector (which is - manufacturer: SmartThings - model: motionv4) to initiate the piston takes the same amount of time.

It is as if the piston is going through each light one by one and verifying its completed the task before moving to the next light in the sequence. This is what appears to be taking so long. This does not happen when you somply tell echo to turn on/off the den lights. They all go on or off at nearly the same time.

I tried to set up a simple routine so I could look at the ST IDE while it ran to do the same thing as this piston, and sure enough after i started the routine, it also takes the same amount of time which leads me to believe that smarthings itself is responsible for the delay and not the piston, nor WebCoRE. Why it takes so long to simply turn on/off multiple lights when echo does it so much more efficiently is over my pay grade apparently.

Any ideas?

Here is the log from the ST routine i set up. Takes about as long IFAIK.

e718ffe2-fe24-42a8-8089-e9cecc6f2efc 2:26:47 PM: trace getPhrases(), state.welcomeIssue = null
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:47 PM: debug Body: [results:[[id:d073d521a8b9, status:ok, label:Den Lamp]]]
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:47 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:46 PM: debug Beginning API PUT: /lights/id:d073d521a8b9/state, [power:off]
bd3b8dc0-7f71-435b-a7f4-d08231db3d4f 2:26:46 PM: debug Device setOff
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:45 PM: debug Body: [results:[[id:d073d521ae66, status:ok, label:Den 3]]]
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:45 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:44 PM: debug Beginning API PUT: /lights/id:d073d521ae66/state, [power:off]
8c30f666-1d17-43c6-8437-b72a61e32f29 2:26:44 PM: debug Device setOff
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:44 PM: debug Body: [results:[[id:d073d52012e3, status:ok, label:Den 2]]]
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:44 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:43 PM: debug Beginning API PUT: /lights/id:d073d52012e3/state, [power:off]
aeddda60-c698-4641-ae24-8e8ae1d8ea2a 2:26:43 PM: debug Device setOff
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:43 PM: debug Body: [results:[[id:d073d521ae12, status:ok, label:Den 1]]]
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:43 PM: debug Status: 207
d1bab21f-2867-4b52-a62d-748b330733b1 2:26:41 PM: debug Beginning API PUT: /lights/id:d073d521ae12/state, [power:off]
86b31e83-50fa-4a55-bfcb-7f678d92ae45 2:26:41 PM: debug Device setOff


#137

webcore. lazy.

ST is probably running those off commands in the cloud where as alexa might be handling them locally first.


#138

well it is a rather significant difference in time. Do you know of any way to fix this? I was thinking maybe giving a mirror piston a try within this piston. Any suggestions? Thanks again.


#139

check your ping times to ST.


#140

I dont know how to do that. Is there a simple way to do it?