Quote from @Koyfam:
I’m working on the latest data now…
Hello,
looking for some help here, not sure what i’m doing wrong.
When I add this ($twcweather.forecast.daypart[0].narrative
) to my expression, it returns the entire array.
When I add this ($twcweather.forecast.daypart[1].narrative
) or any other number inside [#]
it doesn’t return anything.
Same happens when I use:
$twcweather.forecast.daypart[0].uvIndex
$twcweather.forecast.daypart[0].daypartName
I’m a total newbie with this weather data and using it in webcore.
For the next 48 hours, try:
$twcweather.forecast.daypart[0].narrative[0] (Today AM)
$twcweather.forecast.daypart[0].narrative[1] (Today PM)
$twcweather.forecast.daypart[0].narrative[2] (Tomorrow AM)
$twcweather.forecast.daypart[0].narrative[3] (Tomorrow PM)
Just keep in mind that half of the time, [0] will be null… (from approx 3pm to 3am)
Same goes with:
$twcweather.forecast.daypart[0].uvIndex[0]
$twcweather.forecast.daypart[0].uvIndex[1]
$twcweather.forecast.daypart[0].daypartName[0]
$twcweather.forecast.daypart[0].daypartName[1]
etc
Here you go:
$twcweather.forecast.daypart[0].precipChance[0] = Today AM
$twcweather.forecast.daypart[0].precipChance[1] = Today PM
$twcweather.forecast.daypart[0].precipChance[2] = Tomorrow AM
$twcweather.forecast.daypart[0].precipChance[3] = Tomorrow PM
etc...
Just keep in mind that the one ending in [0] will be “null” half of the time.
(approx 3pm to 3am)
You can find the average by using:
( [0] + [1] ) / 2
… but you will need extra code ahead of that to determine if [0] is “null”… and if so, to just use [1] as the “average”.
One observation though…
If you have an AM with 0 percent chance of rain, and an evening chance of 90%, then your daily “average” will be very misleading at 45%.
You forgot to divide your sum by two…
Also, I have only seen even numbers, so rounding the average is likely not necessary…
(unless you decide to round more than two dataPoints)
Yes, you would need to add a step before that line of code…
Something like:
IF [0] is "null"
Then use [1]
Else use ( [0] + [1] ) / 2
END IF
I think you have a bit of strange syntax in your last post, as well as missing data for the “round” command.
If you want to round the answer to a whole number, here is the expression
I would use:
round((sum($twcweather.forecast.daypart[0].precipChance[0],$twcweather.forecast.daypart[0].precipChance[1]) / 2),0)
Changes I made:
Expressions
do not need curly bracketsOne other “food-for-thought”…
After 3pm, when [0] returns null… It is important to remember that the [0] forecast is literally done and over with.
For example, at 4pm, the data from earlier that morning [0] should not really be a factor at all for the rain you can be expecting that afternoon.
Just my two cents.
What I do in my home is to try to determine the rain chance for the next 8 hours. (since I am rarely outside longer than that). This is kind of tough though, since TWC only shows 12 hour increments. My current method is something like this:
From 4am to 8am, use [0] (AM data thru 3pm)
From 8am to 3pm, use ([0] + [1]) / 2 (today's AM/PM average)
From 4pm to 11pm, use [1] (PM data thru 3am)
From 11pm to 3am, use ([1] + [2]) / 2 (PM today + AM tomorrow average)
Just keep in mind that any execution that happen in the 3 o’clock hour may go either way.
(the update time varies quite a bit, as seen here)
Edit 2022:
I have created a piston to outsmart this craziness…
(to make sure that the same query always returns the current data)
Just as a suggestion, it might be nice to include a short paragraph at the top of the Wiki page that explains how to set up and use the $twcweather variables.
I am just getting started with weather so here are my suggestions from someone experiencing this with new eyes.
After searching for a couple of hours, I haven’t really figured out how to set up this feature and configure the specific weather station. Perhaps a brief overview of the steps to set it up, configure the weather station, and then an example piston that does something like turn on a light when the current temperature rises above a certain value.
Also, it might be nice to describe in the Wiki how often the data is updated, and whether or not you can change the interval.
Hope that this helps!
- Brad
Thanks for the feedback. If I may address these one by one:
Variables
can keep track of anything, so are not limited to $twcweather.
(IE: The weather page is not the place to learn about variables
)
There is nothing to setup. (other than telling SmartThings your location)
The data is always available, but it is up to us to make the query efficiently.
Here is one that checks every half hour.
There has not been any public information released, so the $twcweather Wiki contains our own personal observations. I suspect the update time is very different in different locations (since weather providers are different worldwide)
I doubt this is possible yet. I mean, you can change how frequently you make the query, but that does not mean that anything new came in yet.
Typically, I make my weather queries once per hour. Temps every 30 min. Alerts every 15 minutes.
Try to not go overboard though please, because SmartThings is billed for each and every query. We don’t want to abuse it, because they will start charging us for this data.
Try this:
condition
Expression
$twcweather.conditions.temperature
in the boxPerfect! It works great.
Try to not go overboard though please, because SmartThings is billed for each and every query. We don’t want to abuse it, because they will start charging us for this data.
The info about not querying too often would be excellent to include in the Wiki. Now I know to be conservative.
Thanks for your help!
I have a piston that uses $twcweather.conditions.precip24Hour but it seems to only ever report back 0.0. We had a pile of rain the other day but it still reported 0.0. Any thoughts?
Mine changes, but infrequently, and always remains a fairly low number.
I just analyzed two weeks of data, and precip24Hour was 0.00 about 95% of the time.
The highest number I saw was 0.56. (I believe it is in inches for Americans)
If a visual helps, there was 39 consecutive hours where it did have data… (shown below)
0.00 = 5:04 P.M.
0.01 = 6:03 P.M. (guess 0.01 from the past hour)
0.02 = 7:03 P.M. (guess 0.01 from the past hour)
0.03 = 8:03 P.M. (guess 0.01 from the past hour)
0.05 = 9:04 P.M. (guess 0.02 from the past hour)
0.08 = 10:04 P.M. (guess 0.03 from the past hour)
0.11 = 11:04 P.M. (guess 0.03 from the past hour)
0.13 = 12:04 A.M. (guess 0.02 from the past hour)
0.18 = 1:04 A.M. (guess 0.05 from the past hour)
0.22 = 2:04 A.M. (guess 0.05 from the past hour)
0.30 = 3:04 A.M. (guess 0.08 from the past hour)
0.33 = 4:03 A.M. (guess 0.03 from the past hour)
0.33 = 5:03 A.M. (guess no rain in the past hour)
0.34 = 6:04 A.M. (guess 0.01 from the past hour)
0.39 = 7:03 A.M. (guess 0.05 from the past hour)
0.51 = 8:03 A.M. (guess 0.12 from the past hour)
0.55 = 9:04 A.M. (guess 0.04 from the past hour)
0.56 = 10:03 A.M. (guess 0.01 from the past hour)
0.55 = 11:04 A.M. (guess no rain in the past hour)
0.55 = 12:04 P.M. (guess no rain in the past hour)
0.55 = 1:04 P.M. (guess no rain in the past hour)
0.55 = 2:04 P.M. (guess no rain in the past hour)
0.55 = 3:03 P.M. (guess no rain in the past hour)
0.55 = 4:03 P.M. (guess no rain in the past hour)
0.55 = 5:03 P.M. (guess no rain in the past hour)
0.55 = 6:03 P.M. (guess no rain in the past hour)
0.55 = 7:04 P.M. (guess no rain in the past hour)
0.54 = 8:04 P.M. (no rain in the past hour = Notice we subtract the 0.01 from 24h ago)
0.52 = 9:03 P.M. (no rain in the past hour = Notice we subtract the 0.02 from 24h ago)
0.49 = 10:04 P.M. (no rain in the past hour = Notice we subtract the 0.03 from 24h ago)
0.46 = 11:04 P.M. (no rain in the past hour = Notice we subtract the 0.03 from 24h ago)
0.43 = 12:04 A.M. (no rain in the past hour = Notice we subtract from 24h ago)
0.40 = 1:03 A.M. etc...
0.35 = 2:04 A.M.
0.27 = 3:03 A.M.
0.23 = 4:03 A.M.
0.22 = 5:04 A.M.
0.21 = 6:03 A.M.
0.19 = 7:04 A.M.
0.08 = 8:03 A.M.
0.00 = 9:04 A.M. (Finally back to no rain in the past 24 hours)
Note: A few of the numbers may be off by 0.01, which is normal due to rounding.
Yikes! I’m learning all of this all over again. I am in the middle of switching over to Hubitat. ST has become unstable, and is having issues on a daily basis.