Setting up a Piston as a variable "flag" system


#1

1) Give a description of the problem
Hi all! Complete noob here looking to make a piston to essentially act as a high low flagging system using weather.
2) What is the expected behavior?
Ideally this system will use weather data to make certain “flags” go high or low. for example… If the current temp is over 55 than make flag one high. if under 55 make flag 1 low.

I would like to have this with many “flags” and then I can create other pistons to act accordingly with the flag state… for example
If flag one is high than send push notification
if flag 2 goes low than turn on light
if flag 3 goes high than turn off light
etc…

3) What is happening/not happening?
I don’t know where to start… I have done advanced automation on systems that already have this functionality.
I appreciate any help and guidance in this matter.


#2

It sounds like you want boolean Global variables.

IF Temp is above 55  <-- Condition acting as a trigger
    Then Set variable @globalTemp = true
    Else Set variable @globalTemp = false
END IF

Afterwards, that global will be visible in your other pistons.

Just keep in mind that globals are not written until the very last line of code has completed.


Pro Tip:
If it’s the temperature you are interested in, I would likely consider not using boolean flags though. For example, your fan or thermostat can simply check the real temp when deciding which path to take. This is much more efficient, and gives you much more fine control of the outcomes…


#3

Here is an example of PHASES (Flags) that @Wcmore helped me to wrote.


#4

One of the uses of this is to change the color of lights based on the temp at certain times of the day.

At 6:30 am if its under 45 than change lights to blue, else if its between 45 and 70 turn lights to green, else if its over 71 turn lights to red.

the second step in this would be to add the event as well.

If rain than flash lights for 10 mins if snow strobe lights for 10 mins… etc…

Another stage in this would be to ask my smart speaker to give me the weather, this would query the smartthings hub and readout only the information I want, like current weather, forecast for home and work ( I work 2 hours from home so the weather is vastly different.)

I had something like this using a Vera lite with the weather underground plugin and Oncontrols

The plugin gave the weather, oncontrols parsed the XML and change the conditions readout based on the the statements above.

A lot of this that I have done in the past has been with little code on my part. I utilized app plugins, parsed XML data and variable code used was form entry in a app plugin and it spit out the code.

At this moment I am looking for advise on the most efficient course of action. I have read that Nest has pulled its API so parsing data from that will be almost impossible, so we left with using internet weather websites… I would be more than happy to learn how to properly code this, I just need some direction on where to start. Should I use global variables? That is what makes the most sense to me. Should I write each task individually? If so, what is the benefit.

Again I have all intention on learning the code, I just don’t really know where to start here.

Thanks in advance for all the help!!!


#5

All three of your projects are entirely different (and independent) pistons.


Every day at 630
    IF Temp is less than 45, then set color to blue
    IF Temp is greater than 70, then set color to red
    IF Temp is between 45 and 70, then set color to green
END EVERY

Weather cannot be a trigger. It must be a condition. I make mine something like this:

Every 15 minutes
    IF weather contains rain, then do something with the light
    IF weather contains snow, then do something else with the light
END EVERY

You can create a Simulated Switch, and tell Google or Alexa to turn on that switch. At which point, webCoRE can take over, check the weather, and report back whatever you like. I get text to speech via this method.


Again, I must emphasize… all three of these are to be in separate pistons, and none of them require flags.


#6

Thanks for the help! This is perfect!