I am trying to build a weather super tile and need some help writing an expression to filter data.
I have a rule that sets a variable based on the edge weather device attribute.
I then want to take that variable and filter for specific words like cloud, rain, clear, thunderstorm, etc.
Then I want to concat that with day or night based on the time of day. My goal is to end up with a final variable of day-clear or night-clear etc. so that I can set an icon based on the weather.
My rule so far looks like this
Weather device updates
If time is before sunset
Then
set $weatherSummary to device attribute, summary value (this works) // clear sky
set $weatherSummary using expression to look for specific word clear(stuck here)
set $weatherSummary using expression
time=“day-”
concat(time, filtered response) // day-clear
Else
set $weatherSummary to device attribute, summary value (this works) // clear sky
set $weatherSummary using expression to look for specific word clear(stuck here)
set $weatherSummary using expression
time=“night-”
concat(time, filtered response clear) // night-clear
Ok, so if I understand correctly, you can grab the specific icon I.D from your API call, then the easiest way is run your rule of that. Plus you can also create a variable and have it say whatever you want, based on the current icon
Be!ow is OpenWeather Icons and very quick examples
It looks like you are using a different API than other people have mentioned, so the returned data format is different.
As such, you would need to use the appropriate path to an item you’re interested in. There’s a brief explanation on traversing JSON trees here.
Otherwise, I might recommend using something like the following to make it easier to find the appropriate path:
You can paste your JSON response in the left pane, then expand and select your desired item on the right and it will show you the appropriate path. Just replace the x in their path with $context.response.data.
Almost. There’s no top level property called “current” in the API response you’re using. It’s just weather → 0 → icon
Thanks everyone for all the help. This is what I was able to come up with which works perfect for our needs. The icons changes based on day/night/condition.