RM Example: Using a virtual dimmer to store a variable value

There are probably a ton of use cases for something like this. For this example, Hubitat sends me hourly notifications showing how long the garage door has been open.

It uses 2 rules:

  1. Increment the counter every hour while the garage door is open, reset to zero when it closes
  2. Send a notification when the count is incremented

It also uses a virtual dimmer. In the example below the virtual dimmer is called "Garage Door Counter". After you create it, turn it on.

Rule 1 - Increment the counter when true, reset to zero when false

  • Make sure to set the Cancel to truth change option on the Delay, and also set the Stop on truth change option for the repeat

Rule 2 - Send the notification

Result

7 Likes

I am wondering why you used a Virtual Dimmer? Is it because you can count up with it?

Correct. I could do without it, but then I don't get a count of hours the garage has been open.

Could you do this with a Private Boolean?

I'm not following how that would help...can you explain your idea?

Private Boolean only has two states: True and False.

Hard to make a decent counter out of 0 and 1 :smiley:

1 Like

OK, just learning and someone had mentioned PB. I guess I was thinking of them like variables in WC.