Cooldown Period

Hey all, been building dashboards for a few weeks now. Really liking the level of customization. Now for my first question…

I have a tile for my door sensor. Red when it’s open and green when closed. Pretty simple. What I haven’t figured out is how to make the tile stay yellow for five minutes after the door is closed (the cooldown period). This way I can tell at a glance if the door recently closed. If the door reopens before the cooldown, then the tile goes back to red immediately. Is this possible?

You might be able to do it with a rule and a variable.

For example, you might set it up as:

  • Text Variable: $doorStatus
  • Two Rules:
    1. Basic Open/Closed Status
    2. Stayed Closed Status

Rule 1: Basic Open/Closed Status

Triggers:
- Contact changes to closed
- Contact changes to open

Flow:
IF $context.event.value is open
THEN Set $doorStatus to open
ELSE Set $doorStatus to closed-recently

:information_source: Using $context.event.value in the IF condition makes the rule run faster. Rather than asking your smart home hub for the status of the door again, it uses the triggering event value as the condition.

It’s under Variable → Context Variables (tab): Event > Location/Device Event > Value

Rule 2: Stayed Closed Status

Triggers:
- Contact stays closed for 5 minutes

Flow:
Set $doorStatus to closed

Dashboard / Tiles

That would give you a variable $doorStatus which has three possible values:

  • open
  • closed-recently
  • closed

Then you could either just add that variable directly to your dashboard and then customize the icon / style as you see fit. Or you could use a Super Tile which gives you more control over how things are displayed.

image

Here’s an example of the style configuration of a tile using the above variable concept:

3 Likes

Ah that’s brilliant! I haven’t tried it yet but your logic makes sense. Thank you very much.

1 Like

I put this rule in place last April, but since then I’ve added a bunch of new rules and wanted to start consolidating them. Here’s what I ended up with (rule below). Works perfect! Happy to hear if you have any suggestions on a better way to code this.

Instead of repeating the devices status, you can directly get it from the trigger with context variables. It makes for a faster execution of the rule.

How I would make this:
Triggers
Door open, door closed, door stayed closed for 5 minutes.

Door open sets a variable to turn red.
Door closed sets variable to turn orange for recently opened.
Door stayed closed for 5 minutes to turn green.

Re-opening and closing the door, would cancel out the 5 minute rule and keep it orange.

2 Likes

Dang I forgot to use the $context.event.value! Thanks!

1 Like