Groovy 101 help


#1

I need to define a string value in my app that I can write to (yes, no or true, false) and reference (read and compare and start an event handler) during the app. The initial app works great. I’m trying to clean it up some. I need a value I can write to when the app turns on or off an output or gets to different places in the app. That way I know if this app changed an output or another app or switch did. Right now if I manually turn on an output with a switch the app will turn it off because it doesn’t need the output on (example if I turn the ceiling fan on with the switch on the wall the app turns it off because the ceiling fan is not needed right now in the app).


#2

Vaguely difficult to follow your reasoning here, but it sounds to me like you’re basically trying to do automation. Instead of writing a lot of smart apps to solve specific problems you might want to look into WebCoRE. It’s basically a smart app providing an automation framework that allows you to very easily write any number of fairly complex if-this-then-that scenarios.

OK


(Tony Fleisher) #3

Within smart app, there is state and atomicState available that should work for what you are trying.
http://docs.smartthings.com/en/latest/smartapp-developers-guide/state.html

Also Keep in mind that if the app is event driven (subscribing to device events), event handlers are executed asynchronously and they may run in parallel if multiple events are received.


#4

Thanks seen the state used while looking through code and figured that was what I was looking for but couldn’t get it to work or find any documentation on it.