Using Wildcards in Rules

I use heat mats on my front steps to keep them from icing in the winter. Open weather has a large number of snow conditions (light snow, heavy snow, etc…). Rather than writing each into the rule, and to make it more robust if OpenWeather adds or changes a condition name, I would like them to turn on when the weather current conditions from OpenWeather contains the word snow. I have the rule written like this, with * for the wildcard. This does not work. Should I be using a different character?

That’s to be expected as you are using a strict equality comparison. It does not support wildcards, only exact matches.

You could use an expression with one of the many string functions. You could write the result of the expression to a boolean variable and then use that in your condition. Here’s an example that checks for multiple search terms:

input = "There is sleet in the forecast"
searchTerms = ["freezing rain", "sleet", "snow"]
matchedTerms = filter(searchTerms, contains(input, x))
count(matchedTerms) > 0

There’s a few things going on here:

  1. We setup an array / list of searchTerms
  2. We filter the list of search terms to any term where the inputcontains() the term
  3. We count the list of filtered terms that were in the input
    • If the count > 0, that means at least one of our search terms was found in the input
1 Like