Before I start I will explain a few things I have created two virtual switches in SmartThings one called “Guests” & the other “Lighting Automation”, The reason for this is its great to have automation throughout the house but there will always be a reason to disable it. For example if have loads of friends round I turn the “Guests” switch on and the lights will no longer turn off automatically so once they have come on that it, it’s on till I turn it off manually or turn on the “Guests” switch. The switch isn’t really used that offen but I added it when I had a friend come round with a baby he was asleep in one of our rooms and didn’t want the light to come on every time someone went to check on him. To create a virtual switch you can either use the IDE to manually create one or use SwitchMania or VDM (Virtual Device Manager)
We will start with the most basic webCoRE Piston I have with is one for a cupboard
I always set “disable automatic piston state” so I can set it to whatever I want more about this below
I only recently added “disable command optimisation” as it shouldn’t be needed but so far its solved the problem of the wrong light levels being executed. Its to decease the amount of commands sent for example if a light is already on there is no need to send a on command again, disabling it will send the command no matter what.
On my bigger pistons your see why you should define your devices as you could have more than one device in a define. We are also defining some strings so we can storage useful information
Even though I said this was simple I the first line is a webCoRE global variable, This one in particular is the average Lux of the downstairs if that value is less than or equal to 100 it can continue.
Next is if a defined disabledOnSwitches, this would be my virtual “Lighting Automation’ switch which if on continue.
Next is if a defined contactDevices, this would be Cupboard Door which if changes to open continue.
Now if all three are true the light can be turned on again this has been defined above, as you can see I set different levels depending on the mode the house is in.
I would highly recommend you go and create as many modes as you think you need for your SmartThings this can be done in the ST App or in IDE. I went with 5 modes which are Morning, Home (This is day but I never renamed the default), Evening, Late & Night.
If the defined disabledOffSwitces, this would be my virtual “Guests” switch which if off continue
Next is if a defined contactDevices, this would be Cupboard Door which if changes to closed continue
It then turns off the defined Light
On Events From
The next part is more advanced and is only needed to make the webCoRE page more interesting and easier to spot bugs for example my cupboard looks like this.
First I have a On Events From my defined contactDevices this is only need as I couldn’t set the date the way I liked it in the main pistonState next it will update the date each time the door is closed or opened and storage this under contactTime
The next On Events From defined lights switch or level or defined contactDevices contacts, It then updates all the variables for the room and then sets the piston State
Products from Amazon.co.uk
Price: Check on Amazon
Price: Out of stock