Repeat within RM with lights

So, I have had this issue lately, A door randomly gets left open In the house... KIDS

My goal is to resemble most warnings I have in the home with the Kitchen 1 and Kitchen 2 HUE bulbs.

I want these to flash between colors while these doors remain open after the allowed time frame. I will scale the time frame back once I got this working right.

Trigger: If Garage Walkin, front door, or back door are open and left open for 60 minutes.

THEN:
On kitchen 1 and kitchen 2 100%

While the above trigger doors are left open
Repeat:
Virtual switch (Door Left Open): on
( Goal below is to have it repeat the yellow and purple toggling back and forth)
Toggle Kitchen 1 and Kitchen 2: Yellow
Toggle Kitchen 1 and Kitchen 2: Purple
End Repeat

Wait for expression: Trigger doors to close
Off: kitchen 1
Off: kitchen 2

You've put a delay on the two toggle actions but they'll occur at virtually the same time. Either put a Wait (or Delay) between them OR change the the second delay on the purple action to something like 20 seconds.

You may also want to consider using a Required Expression to limit this to a single instance while the repeat is running using the rule's Private Boolean. Setting the PB before and right after the repeat should work.

@pseudonym
I started seeing that with the colors.... Then the virtual switch I wanted at a different interval than the toggling of the colors.. SO I tried this..It works, sort of lol
The yellow is missed sometimes. goes form purple, off then purple again..sometimes the yellow is the outcast... honestly ---- toggling yellow on and off seems to be better all together... easier for my eyes.

ON the private boolean.... I did not understand how you wanted me to implement..
Set PB to true and put before the repeat, then false after repeat?
I have them installed but disabled for now.

Typically when you use PB is true in the RE, the first rule action sets PB to false and the last rule action sets PB back to true. With the way you HAD it, I was suggesting setting PB to false as either the first or second action (shouldn't matter which) and PB to true between the END-REP and Wait for Expression. That would prevent the rule from retriggering while the repeat was running but allow it to retrigger while waiting for all contacts to be closed.

I don't think I'd use a loop within a loop. 10 loops every 5 minutes with something looping inside it every 20 seconds is 150 loops. Assuming a contact stays open, the first 9 loops would toggle the lights 15 times but the 10th loop would toggle the lights without a defined end. Maybe this is what you want but I think I would prefer to have the While loop a set number of times.

One thing you could do is set up the lights in the color animation app (Color Animation | Hubitat Documentation) rather than worry about repeating the colors. Once the expression is reached, you just shut down the animation connector.

I was just trying to get the lights to toggle on and off on a shorter timer than the virtual switch was.

The following works as expected---- per the way its defined.

My only issue is I am trying to figure out how to cycle the lights in a shorter duration that the 5 minutes for the virtual switch.

I shut the door I am testing with expecting the REPEAT to stop.... still shows repeating.. I think this is the timer itself.. I may need to add in cancel timers.

You haven't defined the number of loops for the While so it will run until all the doors are closed. That makes the Wait for Expression redundant and the Stop Repeating Actions after the repeat isn't doing anything. I think you may want to do this

Actions to Run
Set PB False
Dim: Kitchen 1, Kitchen 2
Repeat every 0:05:00 (stoppable)
    On: virtual Switch
    Toggle color: ... Purple
    Toggle color: ... Yellow --> delay: 0:00:10
    Wait for Expression: NOT Window/Door... any contact open
    Stop Repeating Actions
END-REP
Set color: ... Soft White
Off: Kitchen 1, Kitchen 2
Set PB True

The While has been replace by a Repeat and the Stop within the loop should end the repeating as soon as the door is closed.

ok - I get the logic here on this version..
Considering I was WAITING on an expression, I should have used REPEAT actions instead of WHILE ....
Does the END-REP act as a close of argument? Even when the Stop repeating is in the rule loop?

Yes, the Wait will prevent the running all the actions defined within the loop until the Wait is satisfied but functionally it isn't an issue.

Wouldn't it be lovely if there were some reasonably priced zigbee door closers! I mean I don't want to know if a door is open so I can haul myself across the house to deal with it - I want it dealt with automatically :smiley:

No doubt. I have auto closers on all exit doors but I have pulled some tension out of them because my family hasn’t grasped the idea on opening the door and then just letting it go. So they end up slamming all the doors.
I added notes to get them use to it but it was in vein. So. I take tension off them and then they partially start letting them go. I can’t win for losing lol

Here are the ones I used.
Always check for your outside door hinges to be 4” versus 3.5.

https://amzn.to/4aDqsYQ

So, I am back to this.. IT wasn't working as intended, it would not shut off the lights for whatever reason.
I have rewritten this rule to be as such.
Seems to work but I would like to be able to toggle, or flash the lights, in a shorter pattern.
I tired to add "flash Kitchen 1 and 2 but it did not work... They are Hue Bulbs paired to the hub and controlled by a Zigbee switch that is also paired with the Hue Hub.

You can greatly simplify this rule by using the Color Animation App (Color Animation | Hubitat Documentation). It works with Hue Bulbs connected either directly to Hubitat or the Hue Bridge. It will toggle/flash colors as you desire. Just create an instance and have an activator device. The rule would simply be:

Actions:
Set Private Boolean False
Dim lights to the level desired
Turn on Color Animation Activator
Wait for Expression
Turn off Color Animation Activator
Set Bulbs to Color/CT
Turn off Lights
Set Private Boolean True

You would not need to worry about Repeats since the Color Animation would change the colors as you desire at whatever selected interval you want. Once the Wait is true, you turn off the animation, reset the lights, and turn them off.

thank you for the color animation, I never thought of that---- I finally got it to work. I needed repeatable for the door switch for Alexa to yell at the kids. lol

I was confused with Repeat. I thought that once the repeat WHILE door was open, was not satisfied, it would move down.. IT would stay stuck on the repeat and not move.. SO I added another Wait expression within the repeat with stop repeating actions.

My thought process:

  • While any door was open
    Repeat Virtual Switch (Door Open)

When all doors closed, the repeat was to stop and move on to the next line.

Otherwise, why is the WHILE EXPRESSION available if it doesn't move on when the expression becomes false?
Im not sure if I need the wait expression after the end-if.... IT finally worked so I was afraid to change anything else.

1 Like

The flash function is also dependant on which HUE integration you are using, I too had issues with flash not working until I changed my intergration to COCO Hue.

1 Like