Safety Lights and Light Efficiency.. Oh yeah, and I'm new to this


(Tyler) #1

So, like many of the projects take on, I choose to do something that is “simple” but behavioral in fashion so that I can teach myself how to program in the language. I already know several languages but this is one of the few that appears to be solely event based with no means of looping or being able to run a timed cycle run.

So I reach out the community to give me a bit of a pointer in the right direction. Any input, links, references, etc would be helpful.

What I am trying to accomplish is a lighting setup for my front door. I have an indoor light dimmer and an outdoor light dimmer, I also have a contact sensor on that same door. On both sides of this door are motion sensors (multi-sensors) that I want to have illuminate only if the light detected by the light sensor is below a certain threshold and motion is detected.

So…
-If Mode changes to Night turn ON outside dimmer to 40%.
-If Motion is then active, set outside dimmer to 100%.
–If Motion is then inactive, return to 40%
-If Motion is active && contact Opens, set inside dimmer to 100% (also while outside dimmer remained the 100%).
-If Door closes, and motion is detected inside the door return outside dimmer to 40% && set inside dimmer to 40%.
–If Motion is inactive inside, set inside dimmer to 0%.
-If Mode changes to Home, then only perform these options when the light sensors are detecting anything below 50lux.

I am trying to learn how to do device value checks while in the handler for another device. I have tried looking for subscriptions where when values change that they write to a global variable to then have any state change be able to use the same data, but I have really found a lot of action/reaction only and not many staged functions.

Again, any help would be appreciated.


(sidjohn1) #2

What you are wanting to do is very possible and there are a lot of code examples available that do something similar to what you want. The smartapp templates in https://graph.api.smartthings.com and searching github for smartthings should provide plenty of examples to get you started and http://docs.smartthings.com/en/latest/getting-started.html should fill in the blanks.


(Tyler) #3

I thought I had gone through all of the example templates. I will give it another look.

Thanks.


(sidjohn1) #4

If you just want it work w/o reinventing the wheel there is this:
https://github.com/tslagle13/SmartThingsPersonal/tree/master/Director-Series-Apps/Lighting-Director


(Tyler) #5

Oh bejeezus… I highly doubt that this script had zero copy and pasting involved…

Trying the App now through the IDE. Seeing if it something to my liking. Thanks!