High/Low temperature alert with TWC Weather


#1

Hello, I will admit I’m new to WebCoRE as I’ve been a long time Stringify user and with their announcement of shutting down, I’ve been migrating everything to WebCoRE and so far its going well!

One thing I am struggling with is weather. I see that two months ago the legacy weather setup has stopped working, so now everyone has to move to TWC Weather. The problem with this is all the examples I have found reference the old provider which no longer works.

What I am trying to do is set up an IF for if the high temperature for the day is over 85°F, then give me a push notification. (Actually I would have more things in the “then” but I know how to do that, so we’ll use a push notification for this simple example)

I also want to setup another one for if the overnight low is below 20°F, then (etc).

Maybe I’m missing something but I couldn’t find any properties for high/low temperatures in the TWC Weather documentation.

Could someone please be so kind to help me with an example of how I could accomplish something like this?

Thanks,

Scott


Wind forecast assistance
#2

The Weather Channel has a funky API, that can be a bit confusing…

For today’s high, you can query this:
$twcweather.forecast.temperatureMax[0]
anytime between 3:30AM and 3PM.
(it is null the other 12 hours)

For Monday night/Tuesday morning’s low, you can query this:
$twcweather.forecast.temperatureMin[0]
anytime between 3:30AM Monday and 3AM Tuesday.
(it vanishes after then, and will show the low for the following evening/night)


It is important to note that any queries made between 3:00 and 3:30 may or may not be what you’d expect. The time the data changes over can vary quite a bit from day to day. (as seen here)


#3

Hi WCmore, thanks for taking the time to explain this. I think I got the basics setup. Does this look about right?


#4

The numbers in brackets represents how far in the future…

$twcweather.forecast.temperatureMax[0] = Today’s High
$twcweather.forecast.temperatureMax[1] = Tomorrow’s High
$twcweather.forecast.temperatureMax[2] = The next day’s High

$twcweather.forecast.temperatureMin[0] = Tonight’s Low
$twcweather.forecast.temperatureMin[1] = Tomorrow night’s Low
$twcweather.forecast.temperatureMin[2] = The next night’s Low

The farthest you can reach in the future is [15] I believe. (15 days)


Adjusting slightly from what you have above:

Every day at 8:55AM
    IF $twcweather.forecast.temperatureMax[0] is greater than 80
        Then do stuff
    END IF

    IF $twcweather.forecast.temperatureMin[0] is less than 20
        Then do stuff
    END IF
END EVERY

This reduces your piston to only one trigger (which is good).


#5

Hi again WCmore, I’m not sure I follow your recommendation.

  1. How do I set the trigger before the IF statement?
  2. How do I set the Variable to be the full string? It only lets me select $twcweather but nothing more then that.
  3. Another thing I thought of, how do I define the zip code of this weather forecast?

Thanks,

Scott


#6

New statement > Add a timer (and then drag the old code inside the new block)


I never use the $twcweather available in the dropdown.
I use an expression box to type it all out.

temp

(this has the added benefit of showing you the results in the grey box)


It is based on the location of your hub. (whatever you told SmartThings)


Here is a quick piston using the tips from above. I decided to use variables in this so the actual temperature will appear in your notification (without hitting the weather server more than is necessary)

Feel free to change the time during testing so you can quickly see the results…


#7

WCmore, with your help I am leaning more and more each day! I referenced your example (but didn’t cheat by importing!) to edit my code like yours, and got it working! I like the way you have it structured with the variables, so now I’ve learned how to do those!

One more question! I’d like to have this run at two times: 8:55am and 5:35pm. (before and after work). Is there a way I can add both times without duplicating everything for the second time?


#8

Way to go! :+1:

I think that most of us learn better by going thru the process ourselves.


I sometimes remove all triggers except for “IF Time happens daily at” commands to achieve this:

Yes, those first two IFs are empty, and only used to execute the piston. I also ‘beefed’ up the coding logic a bit so you only receive one notification per event. (The previous method might send two back to back if the high and low both were true) I don’t often use ELSE blocks, but with the current wording, it works well.


Side Note:
If you decide to code this piston by hand, be extra careful with the ELSE placements. A careless indent/unindent can break the logic flow.


#9

… and of course, don’t forget that shortly after 3PM you will find:
$twcweather.forecast.temperatureMax[0]
to be null for the next 12 hours…
(which could add more lines of code if you include that logic)


Edit :
I just solved that last issue in a single line. Now the null for half the day won’t matter.


#10

Ha, I did get two notifications this morning! I realized I made a mistake on the time (easy fix), and the low shouldn’t have fired off since it wasn’t below 20°F but I think tomorrow everything will work as intended now that I was able to change it per your suggested changes! And now that I know the fundamentals I can thinker around with this some more and start moving over some more of my flows from Stringify. Thanks again for all your help WCmore!

IMG_6730


#11

Apologies for reviving an old thread, but even 33 months later, this is still an issue with $twcweather.forecast.

To overcome this limitation, I have created a piston to preserve certain data so it is always available… Even during those null times…