Help writing expression to filter data

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
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
concat(time, filtered response) // day-clear

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
concat(time, filtered response clear) // night-clear

I appreciate any help! Thanks

Are you using OpenWeather API?

I’m actually pulling this from the Smartthings edge weather driver but I can use openweather api 2.5 or 3

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




1 Like

What is the api call for grabbing the icon id?

Another option is to grab the weather ID or main vs the summary and looking for specific words. ID 800 is clear.

1 Like

What do the attributes and values look like? Otherwise the api approach works well enough.

The value for summary is the weather description // clear sky

I’m not opposed to using the api call but I’m having trouble figuring out the response data.
Here’s what I’m trying

This is what I was originally asking for help with. I couldnt figure out how to look for specific words

So go grab the Main or ID, you should be able to do something like this in an expression

forecast = $
forecast = $

I’m not next to a computer but once I am I’ll see if I can build a rule to put it all together.

1 Like

@josh Will you take a look and tell me what I’m doingwrong on this api call?*my-api-key*

Here is what is returned in a browser

  "coord": {
    "lon": -111.6817,
    "lat": 33.3698
  "weather": [
      "id": 803,
      "main": "Clouds",
      "description": "broken clouds",
      "icon": "04d"
  "base": "stations",
  "main": {
    "temp": 305.73,
    "feels_like": 306.28,
    "temp_min": 304.37,
    "temp_max": 307.21,
    "pressure": 1015,
    "humidity": 40
  "visibility": 10000,
  "wind": {
    "speed": 4.12,
    "deg": 140
  "clouds": {
    "all": 75
  "dt": 1692376322,
  "sys": {
    "type": 2,
    "id": 2008467,
    "country": "US",
    "sunrise": 1692363082,
    "sunset": 1692411010
  "timezone": -25200,
  "id": 5295903,
  "name": "Gilbert",
  "cod": 200

I’ve tried and all return null

What am I missing?

These return value: null as well

That’s odd. They work for me. I’m using one call 3.0 but I don’t think that makes a difference.

Can you post a screenshot of your rule?

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 $

Almost. There’s no top level property called “current” in the API response you’re using. It’s just weather0icon


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.