Are there redundant options in the Rules Machine?

In my first (ever) rule I'm trying to turn my front entrance light on at sunset and off at sunset +120 minutes.

As I go through the sequence for creating a rule the first screen has an option:

Capability ==> Time of day
Between two times ==> on at sunset, off at sunset +120

Then in the next screen I get to define what happens when the rule is true and when the rule is false.

BUT, I assumed that the first screen defined as "between" would only keep the lights on between the two specified times.

If this is true then what does the screen to define what happens when the above is false (i.e. not between sunset and sunset + 120) control?

In my first trial, the lights did not go off at sunset +120.

Thanks
John

as "between" would only keep the lights on between the two specified times.

Not really. The condition evaluates to True, and then the TRUE action occurs. Eventually the condition evaluates to False and the FALSE action occurs. It does not "undo the action from TRUE." You must define what you want it to do for both cases. This becomes much clearer as you start chaining Rules, one rule causes another to be evaluated.

scap

2018-06-14 21:30:54.271:info Hallway Switch was turned off [digital]
2018-06-14 21:26:22.295:info Hallway Switch was turned on [digital]

Sunset happened to be exactly 8pm today. 20:00 + 120 = 22:00
I created this Rule around 9:26 21:26 and the Rule Conditions show as TRUE, even now, yet the logs show it was turned off at the +90 mark. Clicking Done, yet again at 21:38, the logs got updated:

2018-06-14 21:38:54.938:info Hallway Switch was turned on [digital]
2018-06-14 21:30:54.271:info Hallway Switch was turned off [digital]
2018-06-14 21:26:22.295:info Hallway Switch was turned on [digital]

Something doesn't seem right about this.

I'll update at 10pm, with further logs.

EDIT: 10pm fired off correctly:
2018-06-14 22:00:01.253:info Hallway Switch was turned off [digital]

(Above log entries are for the Hallway Light, this next is the logs for the Rule:)
2018-06-14 22:00:00.129:info JohnRob Test is now False
2018-06-14 21:38:54.650:info JohnRob Test is now True
2018-06-14 21:26:21.000:info JohnRob Test is now True

@csteele

Thanks for sending the time on my question.

I need to think / test some more based on your response.

I need to test this but....
Shouldn't the action be more accurately described as "Select Actions for when the condition Becomes true" ?

John

If I’m not mistaken, isn’t becomes a trigger?

Something else to keep in mind, at least with the Simple Lighting App, sunrise/sunset events are scheduled at 2:05 am. A rule you build may not work for the first cycle. But, you can check if it’s scheduled by clicking the blue “I” for that rule.

@bjcowles

"If I’m not mistaken, isn’t becomes a trigger?"
I would agree, however on my screen it only shows "between" not becomes.

Scheduling at 2:05 AM. Thanks, that would explain why I saw some with 2:05AM on it but I passed it off as some error. I don't recall the exact screen. I'll watch for the action tomorrow night.

John

Rule Machine is event driven, be it for a rule or a trigger.

If you define the condition Time of Day, think about when that becomes true. It becomes true at the first time, and then it remains true until the second time. What actually happens is that at the first time an event happens that sets the rule to true. Then when the second time happens another event happens that sets the rule to false. In response to both events the rule is evaluated. Upon the first time, it is true, and upon the second time it is false. So Actions for True will happen upon the first time, and Actions for False will happen upon the second time.

In the case of a trigger, Time of Day is not an option, because Triggers don't evaluate any rules. They simply respond to events. For a trigger one would use Certain Time. When that Certain Time happens, the trigger will do its Actions. It does not have Actions for True and Actions for False, just Actions.

So this could have been done with two triggers, or with one rule. I'd use the single rule myself.

2 Likes

Consider a more complex situation:

Condition One: Door is open
Condition Two: Time is between 8 and 10
Rule Cond-one AND Cond-Two

At 8 the rule is evaluated. If the door is open, the rule is true, and Actions for True happen. Suppose the door is closed at 8, then at 8, the rule will be evaluated and it will be False, so the Actions for False would happen (if any). Suppose at 9 the door opens (event!); the rule is true and Actions for True happen. Then at 9:15 the door closes, rule becomes false. At 9:45 door opens, rule becomes true, then the door stays open and at 10 the rule becomes false. Door closes at 10:15, and the rule is still false, so nothing at all happens, no actions take place.

If the door opens and closes at other times, nothing will happen, because the rule will be false the entire time, and the truth value of the rule will not have changed. Actions happen only when the truth value of the rule changes.

1 Like

Argh, this is some very old code that needs to be replaced. It should not be using this method to schedule sunrise and sunset related events.

Note to self: Fix sunrise/sunset scheduling in Rule Machine and Simple Lighting. In the proper implementation, it will know that it needs to schedule something that might happen before 2:05 AM.

@bravenel

I understand now. I was taking "between" literally.

So for your example:

Whenever:
"Condition One" & "Condition two" changes from false --> true, the true actions are invoked.

Similarly:

Whenever:
"Condition One" & "Condition two" changes from true --> false, the false actions are invoked.

Which is essentially the same as what you said with your "Rule Cond-one AND Cond-Two"

So if the kids come home from school at 3:30 PM and within the next hour open and close the door 20 times. The true action will be invoked 20 times and the false action will be invoked 20 times

Its funny how some things can be completely logical, but if you start with a wrong assumption you just seem to continue out into left field.

John

Not in the example I gave with the two conditions!

In that example, since one necessary condition was between 8 and 10, the kids opening and closing the door 20 times at 3:30 will not affect rule truth. It would be false the entire time, and nothing would happen -- no actions true or false would happen.

Now, if the time specified had been between 3 and 5, then yes, the actions would happen each time.

Understand?

Yes, Somehow I got the idea your example was 8:00 AM to 10:00 PM.

Would have been nice if the US converted to metric and military time when I was in grade school.

John

Haha, and I left off am and pm. My bad. So, yes, that was 24 hour clock time. :sunglasses:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.