I'm not sure what to do here, I want to announce my garage door is open from sunset to 11:30pm if the door is open for an hour (set temporarily to 5 min for testing)
I'm not sure what is going to happen after this condition becomes true and the door is not closed. Is the rule going to continuously announce the door is open? I saw someone use a While Repeat X times every X minutes option but I don't understand how to get the interface to setup that condition.
I also setup a test rule to make sure the Google Chromecast is working, it does but after it announces the audio it ties up the device for about a minute, is there a way to release the device quicker?
If didn't work. I opened the garage door at 7pm. Is the logic that it only tests for 5 minutes being open? Or is 5 or greater? Should I close the door, reopen and then see if it works exactly at 5 minutes?
Ok so that's the issue, when I closed the door, reopened the door, 5 minutes later it announced the message. So how do I fix this so that if the door has been open for many minutes before sunset that it will work. I don't see an option for X or greater.
The trigger is only running when the garage door contact changes to open within the time period restraint, so if the door is open early it does nothing, as you observed. The easy fix here is to move the time constraint to Sunset minus X minutes as the starting time. If moving the window back isn't what you want, you may want a monitor that can check the garage door status on an interval and go that route. I'm pretty new to Rule Machine to there may be a better way.
Iām certainly no expert with RM but have tried something similar (without the scheduled time constraint), so take this with a grain of salt, LOL.
Your required expression is ok as it will limit when the rule will actually be triggered. So if you want this to actually announce if the garage door has been opened for one hour prior to sunset (in order to hear the actual announcement at sunset) you need to set the Required Expression so that it runs one hour before sunset.
In addition, if you are potentially opening and closing the garage door (at various time intervals, you want to make the rule trigger when the garage door contact āchangesā. You can then use a conditional, i.e., IF the garage door contact is open for 5min (for testing), THEN speak on ZBathroom clock etc. AND repeat announcement every xxx minutes (if you wish) and making the repeat cancellable. Will also need a ELSE IF garage door contact is closed, THEN cancel repeat and exit rule. End the rule with END IF. This way, you can be assured that your timer will be reset each time the garage door is closed (this is needed particularly if you use a Cancellable Delay between the condition garage door open and the announcement (rather than a single trigger āIF garage door contact is open for 1 hour).
One advantage of using a Cancellable Delay rather than just āIF garage door contact is open for 1 hourā is that you can set up a local variable for the number of seconds (in your case 3500) for the delay, which can easily be adjusted on the main rule page. I find that this keeps you from having to go into the Conditions each time to modify the time of delay when you are tweaking your system. It is easier now to make these type of changes with the new RM UI, but in the past, this is how I dealt with making multiple timing changes (using local variables) from the main page of the rule, without having to go through the more complicated layers of having to change the time within the rule itself.
Again, give this or a variation of this a try, YMMV. Good luck. Hope this helps.
Another method to try that might do what you want. Create a rule that flips a hub Boolean in one rule then use that in the main rule:
Trigger
ādoor opens and stays that way 5 minutesā
Action -
āset variable doorOpen Trueā
āWait for event door closedā
āSet variable doorOpen Falseā
In the main rule the required expression would be the same as before then:
Triggers
āTime is sunsetā
āVariable doorOpen reports trueā
Actions
āIf time is sunset and doorOpen is True thenā
āRepeat while true x timesā
āSpeak on bathroom clock etcā
āEnd repeatā
āEnd ifā
āIf Variable doorOpen reports true thenā
āRepeat while true x timesā
āSpeak on bathroom clock etcā
'End repeat'
āEnd ifā
The Boolean will change state to True whenever the door is open for 5 minutes. The main rule should trigger at sunset immediately and if the door has already been open for 5 minutes at the time(Boolean already true) - carry out your actions. Otherwise itāll skip all the actions but will trigger again if the door is opened and stays open during your time constraints.
I think that should workā¦..
Apologies for the awful formatting - Iām using my phone
Iāve been working on a similar rule, but controlling a light. The light needs to turn on if the doors are open at trigger time, or after (and repeat if necessary.) I created 15 versions and settled the first one below. The second resends the color or off command every iteration. The variable firsttime used in the first rule is to prevent resending the color command. I offer both as an example and not necessarily the answer to your situation, and not as the best solution to either of our situations.
For now I took out the logic for how long the contact has been open. The rule will notify me if I left the garage door open after sunset.
For those wondering what I am trying to do. I am in the garage which is my workshop and I forgot to close the door. It could be hours and once it gets dark I need to get that door closed before someone decides to rob the place. The 5 minute logic was there so if I open the door to take the garbage out (after sunset) for example it would not broadcast the message. For the few times that might happen I can live with the broadcast message.
I really whish the contact option had a greater/less than condition, that would easily solve the problem.