# Rule Machine® Introduction

This is a long thread and my post might be better elsewhere.

To make it short, I found the Capabilities and Rules section difficult to internalize. I understood them but, hadn't really "got it". What helped me was this mathematical metaphor.

For instance:

__Example#1 ________________________________________________

Capabilities:

X = Time of day between 8:00 PM and 7:00 AM
Y = Garage movement sensor active

Rules:

Rule#1 = X AND Y

Actions

If Rule#1 is true Turn on garage light
If Rule#1 is False blank (do nothing)

__Example#2 ________________________________________________
Example #2 got me off on the wrong "foot" because the capability and rule looked identical in the app.

Capabilities:

X = Time of day between 8:00 PM and 7:00 AM

Rules:

Rule#2 = X
(in app this reads exactly like the capabilities)

Actions:

If Rule#2 is true Turn on front entrance light
If Rule#2 ii False Turn off front entrance light

I'm not suggesting changes, just my understanding presented in a different manner for those who have the same twisted mind as I.

John

1 Like

A "difference" between Capabilities and Rules only begins when Capabilities is greater than one.

It's pretty obvious what the Rule needs to be if there's only one capability. As a result, RM auto-populates the Rule.

When there's more than one Capability, RM can't (or shouldn't) guess if you want an AND or an OR, and therefore leaves it to the human to fill out the Rules section.

It should be noted that I have altered a Capability (ie, a switch changed from using a switch Driver to a sensor driver) and have the Rule section go "blank"

Therefore, independent of RM helping out, it's best practice to review the Rule section of every RM Rule as they are built and if a change to a Capability is made, IMHO.

When there is only one condition defined for a rule (single capability selected), that rule is "trivial". The rule part of it is very simple, i.e., when this condition is true. There is no other logic.

What happens is that in that case RM doesn't require you to actually define the rule logic, since it's obvious from the single condition. Hence, it fills in the rule for you. When that rule is evaluated (some state change for the selected capability), it looks at that single condition to determine rule truth.

Note: a rule with a single condition and with only actions for true is identical to a trigger. And, it's marginally faster to use a trigger in that case instead of a rule.

Has anyone managed to make the local endpoints work through RM? I am having a difficult time here...

I didn't realize the difference. Good tip.

Thanks!

I think there may be a problem with the release. Checking into it now. Will get back to you.

Thanks for the reply. Actually it was one of your earlier replies to an earlier RM question that got me on the right track (thanks again). However it was like I was listening to another language and had to translate it to my language to understand it. (i.e. not internalized) . Once I made the mathematical equivalent it "clicked" for me.

## Rule Machine Feature Change

Due to problems with Periodic triggers for Every N Seconds, and Every N Minutes, these features have been removed from Rule Machine.

The same things can be accomplished with Repeat These Actions (in the first Action selection group). You will need some way to kick off the rule or trigger, but whatever action was being used with Periodic can be repeated using this new feature.

Repeat These Actions is available for Seconds, Minutes, and Hours. Such repetition in a Rule can be made to stop automatically upon rule truth change. For a trigger, it can be made to stop with another new feature, Stop Actions (in the last Action selection group).

I can confirm it works BUT with Conditions being always True, the log never shows the Rule running. This is quite correct, just different.

As you can see below, the logs show the polling is firing, but with no intermediate log line for the Rule.

``````dev:285 2018-07-21 08:17:48.413:debug motion inactive
dev:167 2018-07-21 08:17:34.291:info  LivingRoom InWallDimmer is off [physical]
dev:521 2018-07-21 08:17:29.303:info  BBQ Switch is off [physical]
dev:692 2018-07-21 08:17:29.232:info  KidsRoom Wall Switch is off [digital]
dev:285 2018-07-21 08:17:24.113:debug motion active
dev:285 2018-07-21 08:17:11.388:debug motion inactive
dev:167 2018-07-21 08:17:03.118:info  LivingRoom InWallDimmer is off [physical]
dev:521 2018-07-21 08:16:58.158:info  BBQ Switch is off [physical]
dev:692 2018-07-21 08:16:58.066:info  KidsRoom Wall Switch is off [digital]
dev:272 2018-07-21 08:16:51.712:debug motion inactive
``````

Again, it's perfectly correct since the Rule is started once and then runs forever. Thus the only log line would be when it starts. (In my case, 3-4 days ago.)

Is this a feature you plan to make happen?

Since we are asking for things... would it be possible to add capabilities for the attributes aligned with Netatmo devices.

Have you tried @Cobra 's Weather Switch ?

That relies on WU, can it integrate into Netatmo?

Not quite...
WS will work with any weather driver or device that presents the correct attributes
Which specific attributes do you want to switch with?
I can possibly add a few if WS doesn’t work for you.

If you have the driver code for Netatmo, why not just change the attribute to ‘standard’ ones that all the apps (inc WS) use?

Andy

I don’t mind adding a couple of missing attributes but your drivers just use different names for most of them.
I’m sorry but I don’t have the time to completely rewrite the app just for you
Why don’t you just rename the attributes that the driver presents?

Ok. Tell me how they lineup with tour attributes?

Rather than hijack this thread any more than we have done.
I have created a new thread here:

4 Likes

This bug was fixed in the last release, 1.1.2.

How would I make rule that :

Turns Kitchen light off if there is no Motion from kitchen motion sensor for 15 minutes and if the Kitchen Light switch is on ?