Weather Forecast in Lights!


#1

I put together a piston that checks tomorrow’s weather every night at 9:45, right before we go to bed. It turns my cabinet lights blue if rain is expected, purple if it will snow, and yellow if it’s going to be clear and sunny. It does nothing if it’s overcast or cloudy.

Here you go!


#2

Just a suggestion, you may be able to shorten that up a little bit:

IF
{matches(conditionstomorrow, ‘/snow/flurries/freezing/sleet/’)} IS (value) TRUE

matches() isn’t documented on the wiki, but it is available to use and it works.

EDIT: The format should be {matches(conditionstomorrow, ‘/snow|flurries|freezing|sleet/’)} "note the vertical “|” not a slash “/” in the regular expressions


#3

Or even:

if
    {conditionstomorrow} is any of 'snow,flurries,freezing,sleet'

I do this in a piston I wrote that estimates the outside illuminance level based on current conditions.


#4

Good ideas. I’m not at all a programmer, so I kinda stumble my way through this stuff. I used ‘contains’ because ‘sun’ will match sunny, partly sunny, mostly sunny, etc. The same is true of the other conditions. I suppose you could use ‘matches’ if you want to put the whole list in there and use the full text for the weather conditions. :slight_smile:


#5

Good point about matching multiple things. FWIW, in my piston I use icon instead of conditions because it’s a much smaller list (and because that’s what the SmartApp did that I stole, er, plagiarized from. :wink: )

Check out: https://www.wunderground.com/weather/api/d/docs?d=resources/phrase-glossary

You’re using what’s under Current Condition Phrases, whereas I’m using Icon Name under Forecast Description Phrases.


#6

matches() will also be true for multiple things, example:

{matches(conditionstomorrow, ‘/part|snow/’)} will be true for “partly sunny” or “snowing”

So it looks like contains() allows you to match just one thing, where matches() allows multiple items.
Gotta love (and sometimes hate) how there’s so many ways to accomplish the same thing!


Creating and Accessing a WebCore String List (Text)
#7

quick question. At the very top when you define condition tomororw. You use {lower(

what does the lower portion of the code define here?? Rest makes sense to me.


#8

never-mind… I believe its lower case.


Contains() function with multiple values