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:
- Two Rules:
- Basic Open/Closed Status
- Stayed Closed Status
Rule 1: Basic Open/Closed Status
- Contact changes to
- Contact changes to
THEN Set $doorStatus to
ELSE Set $doorStatus to
$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
- Contact stays
closed for 5 minutes
Set $doorStatus to
Dashboard / Tiles
That would give you a variable
$doorStatus which has three possible values:
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.
Here’s an example of the style configuration of a tile using the above variable concept:
Ah that’s brilliant! I haven’t tried it yet but your logic makes sense. Thank you very much.
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:
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.
Dang I forgot to use the $context.event.value! Thanks!