Rule Logic If Count Stays for x Minutes

Hi All, I have weather station that captures lightning activity. Every minute, a rule runs that captures the total count for the day and the most recent strike’s distance.

A supertile shows how many lightning strikes and the distance to the last strike. If #WeatherLightningCount > 0 then the tile is highlighted (purple). When the storm passes, it’s still highlighted, but that’s not what I want.

What I want is if the tile #WeatherLightningCount hasn’t changed for 10 minutes, then turn the tile back to its default state (green). The tile will continue to show the strike count for the day, but it reverts to its default color state.

These are my current variables:

  • #WeatherLightningDistance
  • #WeatherLightningCount
  • #WeatherLightningDate (captured in ISO 8601 format)

Alternatively, I think a date function would work too but I don’t know how to have a rule run IF #WeatherLighntingDate is > 10 minute ago, THEN revert the tile to green.

So, I don’t know how to get either option to work :smiley: .

Screenshot 2024-05-19 105449

Thanks for taking a moment to read my post!

I suspect that you would need to calculate a separate variable that combines these two conditions into a single variable. If I understand that logic correctly, you want the tile to be highlighted when the LightningCount > 0 and the last strike was within the last 10 minutes?

Here’s an expression with some sample variables that you can play with:

timezone = null
count = 2
lastStrike = date("2024-05-20T17:18:57Z")
tenMinAgo = addMinutes(now(), -10)

count > 0 and lastStrike < tenMinAgo

In your case, you could substitute the hardcoded strikes and date string for your variables.

Pretty close to the logic I think I need, which is:

  • Tile is green if there hasn’t been lightning in the last 10 minutes.
  • Tile is purple if there has been lightning in the last 10 minutes.

I think you gave me enough to go on. I’ll play around with that and reply back with the end result.

Thank you!

Here’s what I did. I created a variable called #WeatherLightningRecent. Then I built two rules. One updates that variable to either “active-tick” or “active-tock”. A second rule changes the variable to “idle” if the variable stays “active-tick” or “active-tock” for 10 minutes. It does what I want!

Screenshot 2024-05-20 212735