Trying to make that first leap


#1

Hi. I am new to webCoRE… very new. I am having a hard time wrapping my below psuedo code into what needs to go into the dashboard. I have been able to test individual snipets/commands, but cannot tie it together. Any assistance would be great!

My “device” is a GE Z-Wave Dimming Switch and is wired directly to my garage lights. I want to dictate when and how the lights come on.

Part1
if device physically transitions to the on position
then ignore everything below but the physical switch to ensure the light stays on and set to the level physically commanded
elseif device currently turned off and time is between sunset-30min and 9pm or 5am and sunrise+30
then turn on the device and set the level to 50

Part 2
if anyone arrives home and time is between sunset and next sunrise
then capture the current state of the switch (as in physically on vs. programmed on and its level)
then turn on if required and set the level to 100
then after 10 minutes restore the previous state of the switch

Part 3
if the device physically transitions to off
if it was physically turned on and between sunset-30min and 9pm or 5am and sunrise+30
then turn the device back on and set the level to 50
else leave the light off until the next time or arrival trigger.

Thanks for any help or specific examples I can leverage.

Frank


#2

Have a look in the ‘Example Pistons’ category.
Lots of examples of different use cases.
This should give you ideas.

https://community.webcore.co/c/Examples


#3

My first concern is the physical part of the switch… I thought I read somewhere that some switches that used to report isPhysical are no longer working, I don’t remember the exact reason.

Edit: I guess it still works and recommend to contact ST support if suddenly it doesn’t.


#4

I’m glad you mentioned that. I have Lutron Caseta dimmers and the “physical interaction” filter isn’t working. The one piston I used that in fights itself and puts on a heck of a light show.


#5

ST removed the logic for isPhysical in their standard Z-Wave Switch handler. Their reason was that it was not working consistently, but it worked fine for me .

It was still in the template version (don’t know if ST changed that since) at the time, so I copied that to My Device Handlers to use.


#6

Just create a variable set to true if physically pressed and to false if you trigger the lights to go on by means of your piston. Then use that variable as a condition to stop the piston from firing where you want it to.

Define physical = / * * /

If switch changes to on
Then set {physical} to true
End if

only when {physical} is ‘false’
If someone presence chsnges to present
Then
With switch
Turn on
End if

If switch changes to off
Then
Set {physical} to ‘false’
End if

To start this piston you will need to manually turn the switch on first. From there it should work as desired. Adapt as necessary. I threw this together quickly, so yo may need to do a little troubleshooting, but should get you started.


#7

Ahh, I think I follow. This should be fun.


#8

Here is mine using a motion sensor and smart light switches. For my kitchen

My motion will change to inactive after only a few seconds, regardless of continued motion or not. Then will recheck fo motion every 4 minutes or so, until it finds motion. Then repeats that cycle. Thus the 5 minute wait statements.

If the motion was the trigger for the lights to turn on, and no motion, it will turn off lights. However if it sees motion again it will reset the 5 minute wait timer., and start over.

If you manually turn the lights on, they will stay on until you turn them off manually.

If motion turns them on, and you want them to stay on indefinitely, you would need to manually toggle them and they will disable the motion checking part of the piston.

Hope this helps


#9

Can you explain how only-when statements work versus traditional if-then statements and why this is advantageous for these situations?

Thanks!
Frank


#10

they are much similar. However I have found that, the only when condition will reduce the amount of if statements you will need and only check the ones that pass the only when condition first. Thus reducing the amount of complex ifs or multiple ifs that can be determined by the only when condition.

Just the way I do it, there is more than one way to skin a cat :nerd_face:


#11

Here is what I am testing. Thoughts?


#12

Physically may or may not work for you. It depends on your switch and if it supports it.