Question about weather forecasts


#1

1) Give a description of the problem
My wife would like our RGBW under cabinet lights to light up based on the day’s forecast high. I found this piston, however it works based off of the current temperature and not the forecast.


Since the forecast high returns today and the next 3 days, I’m not sure how to pull out the result. On a side note, I’d also like to put in a flash for if it’s supposed to rain or snow, but learning how to deal with the high results might help me with that

2) What is the expected behavior?
display a color based off of the current day’s forecast high

I think I understand how to code it to make the lights come on and when, it’s just confusing how to deal with the results for the forecast high since it doesn’t return a single number. It returns something like this instead:
[[celsius:32, fahrenheit:89], [celsius:33, fahrenheit:92], [celsius:34, fahrenheit:94], [celsius:34, fahrenheit:94]]

Thanks


#2

take a look here:

https://wiki.webcore.co/Weather


#3

If you still can’t figure it out then either of us would be happy to point you in the right direction


#4

So I’ve looked at the Weather wiki, and that’s where I found the command $weather.forecast.forecast.simpleforecast.forecastday.high to get the forecast high. But my problem is what to do with it since it returns something like this… [[celsius:32, fahrenheit:89], [celsius:33, fahrenheit:92], [celsius:34, fahrenheit:94], [celsius:34, fahrenheit:94]].

I created this piston to show if there’s going to be rain. But the precipitation command ({$weather.conditions.current_observation.precip_today_in}) returns a decimal and not a long string.


#5

When you get multiple results like this then you can filter them down in a couple ways. You are getting 4 pieces of information each containing two sets of info. So to limit the two sets you just add the name of the info to the end of the original request.

This will return the 4 results of Celsius.

This will give you the first result of Celsius.

Anytime you get multiple results back you can limit them with an index starting the 0.

There are fancy ways to pull all them with a for each statement but for now that should get you going.

Not sure i follow what you are asking but certainly change the variable from dynamic to decimal


#6

Thanks, that’s exactly what I couldn’t figure out!


#7

Awesome!! I kinda touch on it in the wiki but i don’t mention too much about the indexing on that page.

Anyway glad you are getting it figured out


#8

@c1arkbar How would I retrieve yesterday (as well as the day before) data, e.g. rain inches? I tried forecastday[-1] but that didn’t work. It must be there, but I didn’t see historical data retrieval in either the Wunderground wiki or the webCoRE weather wiki. Thanks for your help.


#9

$weather.yesterday.history

But until I document it you will have to parse through it to find the info you are wanting.

When I originally did the $weather page I don’t think it worked. Hence undocumented. But I just tested it and was getting results.


#10

I got around to looking at that big text response today (on my tablet) and then tried to analyze it on a computer and - poof - it is now only giving me a “null” response. Maybe related to the webCoRE DST craziness today?

Since I can’t see it, I’m not sure… Does it give precipitation data for day-before-yesterday?

Thanks!


#11

[response:[error:[description:a requested feature is not valid due to exceeding rate plan, type:invalidfeature], features:[:], termsofService:http://www.wunderground.com/weather/api/d/terms.html, version:0.1]]

I am getting this error when attempting to use the $weather.yesterday which is probably due to the DST craze


#12

It’s working again for me. But, wow!, that’s a lot of text data. I’ve picked through it and I’m not seeing a data point of accumulated rain for one day before. I was hoping for one or two days previous historical sum by day, in the same way the forecast allows “[1}” or “[2]” as parameters looking forward. I guess nothing like that comes from WU.


#13

Ok so I’ll still need to go through that to find all the data points but you should be able to do $weather.yesterday.history.observations.precipi

$weather.yesterday.history.observations.date.pretty
Will show when things are pulled from

You can add an [index] after observations to limit it to a day or span or days

Also if you don’t want imperial and would rather have metric than change the i at the end to m


#14

That helps. I feel like I’m making progress - thank you. Whether I use precipi or precipm, I get -9999.00. Is that me doing something wrong?


#15

Usually means there was no rain


#16

I have a couple questions about the history api:

  1. Does this support any of the calls or only specifically what you enable? There is a “snowfalli” parameter that will give the actual inches of snowfall per hour (as opposed to a 1 for snowfall vs 0 for no snowfall that returns with the “snow” parameter) that I am interested in

  2. You mention getting data from a specific day by using an index, but that call always gets yesterdays observations. It returns an array of each hour for the 24 hours in the previous day. Adding an index just allows you pick one hour of that day. I tried:
    "$weather.history.observations.date.pretty"
    (and also with an index after observations) but it just evaluates forever and returns nothing. I also tried:
    "$weather.20180201.history.observations.date.pretty"
    (for Feb 1, 2018) and again got nothing. Is there a way to get data from a specific date in the past?


#17

I am not seeing the snowfalli under the yesterday data point. You can find all available data for yesterday located here and using the menu on the left you can see the other data points as well.

All of the info you find on that page is accessible using the expressions. Nothing to activate.

You can not specifiy an exact date to pull data from. At least not that I am aware of. On some of these apis you can use the index to select a day and some are just hours. As you noted this is just hours. Here is how you would limit it

(expression) $weather.yesterday.history.observations[5].date.pretty »»» (dynamic) 5:53 AM CST on February 03, 2018

This is the 6th piece of data in the set (these are zero based indexes). So for 24 hours it would be 0-23.


#18

Thanks, the specific date call I was referring to is in the WU API documentation here:
https://www.wunderground.com/weather/api/d/docs?d=data/history

So I figured by following the formatting for other calls and looking at the json response, I should get something back with:

$weather.history_20180202.history.date.pretty (for Feb 2, 2018)

but the expressions viewer just gets stuck evaluating and never gives me a response. Is my syntax off here? If everything on that page is available via the expressions I should be able to get to this but I’m having a heck of a time getting this call to work. Thanks again for helping me through this.

EDIT: Spelling(s)


#19

I have also tried getting this to work and it just hangs. There is probably an error being thrown somewhere that is not obvious because of the channels we are going through.

If you really wanted to use to use this data set then you could look into getting your own personal API key and then make an http web request as the documentation states and then scrape the json response.