Wanting to learn a new way to do this

Hi folks. I have two rules that can do the same thing(pretty sure) - one in Basic Rules and the other in Rule Machine.

image

In Rule Machine

There are 4 switches for the 4 pump speeds. The basic idea here is when one switch is on, the others need to be off.

The Basic Rule works great but I was thinking I could rewrite it differently using Rule Machine as an experiment. Since Actions seem to run from top to bottom, this is what I came up with. The problem I'm having is the IF statement only does one thing and I want it to do several.

For example I want to do something like this and I'm using the 2nd IF statement in Rule Machine as an example;

If(Time is 8:01 AM) On: Speed 2 "AND" Off: Speed 1. There isn't an "AND" so I had to add an additional IF statement to turn off Speed 1.

Basically what I'm trying to achieve is at a certain time trigger, turn one switch on THEN turn off any of the other switches that are currently on.

And yes, I do want to turn the next speed on before turning the previous speed off. So for a brief moment, there will be 2 speeds "On". This is fine.

What would be an efficient and practical way to do this to the more experience folks out there? Like I mentioned earlier, the Basic Rule works fine. But I'm curious to see others "logical process" in figuring out how to do this.

Thanks,
Jeff

Did you use a 'simple condition's to add those IF statements? You'll have to re-create them, but a standard If-expression-then will do what you want. That allows for multiple condition evaluations (if this AND that) along with multiple actions.

1 Like

There are two kinds of conditional statements... what you're using in the rule above is a simple conditional. But the other kind, IF expression THEN, will allow you to execute multiple statements.


Just make sure to add an END-IF statement after the block of statements you want to execute.

You can also use logical AND and OR in your statements.

I think your basic rule is pretty straight forward and seems to cover it quite well. If I did it in RM I probably would have duplicated what you did with the basic rule.

Trigger at 7:01, then set switches and use wait until time to do the next switch implementation

I would leave the basic rule in place. No need to redo it in RM

1 Like

I guess what I'm misunderstanding is the need for Conditions for my specific case. I don't need to check or evaluate anything. I just need... at this time, this to be on and that to be off. Period.

Example;
Lets say its Saturday and there are too many leaves in the pool. The schedule is running and I make a change by manually turning off speed 2 and turning on quick clean. Now when the time comes for speed 3 turn on, quick clean will be on instead of speed 2. The schedule will turn off speed 2(already off) and turn on speed 3. Quick clean will also be left on. Now you could create conditions but I don't think they are needed. When it's time to turn on speed 3, turn off all others.

rcjordan, I installed One at a Time via Bundle Manager and created a child. Where do I create the setting where I want one specific switch on and the others off?

On a side note, I noticed Bundle Manager showing my Abacus Counting Machine at ver 1.0.6 but if I open Abacus Counting Machine, it's 1.0.5.

edit: Nevermind the version difference. Just happened to look again and it's 1.0.6. Guess it took awhile to update even thought Bundle Manager showed updated.

A time check is a condition. You are evaluating what time it is. Simple conditions are a single check to remove some of the extra items you'd have to configure (making it simpler to setup) but limit what you can do. With standard if-then statements, you can achieve what you want.

IF('time' is "7:01 AM") THEN
On: 'Speed 1'
END-IF
IF('time' is "8:01 AM") THEN
On: 'Speed 2'
Off: 'Speed 1' Delayed "xx time"
END-IF

Repeat the evals for for each time. I'm not sure that "One at a Time" is what you want. I haven't used it/seen the configuration options, but, on the surface it will immediately turn off the other switches when one is turned on (no delay period). If that's an option, you could get right of the "off" lines in and just use simple conditions like you tried to above. If it's not configurable in that app, and you do want the overlap, then you'll need to setup the rule like my example here.

Create a child app. Under "Devices to control" select the switches in your group -- speed 1. speed 2, etc. That's all you need. The app takes care of turning off all the others in the group when one is turned on.

rcjordan, ok wait a second, let me think this through. You're saying if you have several switches and select them from within the child app, only one of these will ever be on at once? Like this is some sort of stand alone babysitting nanny monitoring those switches allowing only one to be on? And you don't enable it in a rule either?

I wanted to test this myself using a MHCOZY 4 relay 12V ZigBee Switch for my pool pumps 4 speeds. I enabled the 4 relays in the child app and clicked done. I went out to the pump and changed speeds manually by pressing the buttons on the relay board. Each time I selected a different relay, the old one turned off automatically. Pretty clever.

So now I can go into Basic Rules and just create different ON times for the different speeds with a final OFF time at the end of the day. The app automatically takes care of the individual OFF's during the day.

Thanks for responding otherwise I wouldn't have known how deceptively simple this app is to use. The generic description you give in the app doesn't do the functionality of the app justice. And let me add this, and I'm saying it to all app developers. If you spend hours developing an app, spend an additional 5 min by taking out your phone and recording a 1 min video with an example of it's use. Then post it on youtube. Sometimes visually showing can be better than explaining.

Hat tip again rcjordan.

2 Likes

bob692006, thanks for the explanation and example. This is what I hoping for and I learned something new. I was able to duplicate this and may try this on some other rules I have.

Thanks again,
Jeff

1 Like

To go along with this you can also do:

IF ('time" is 07:01) AND ("Speed 1 is off" OR "quick clean is on") THEN
{This uses a sub expression}
If ("quick clean is on") THEN
Off: quick clean
Wait for 1 second {gives zwave time to communicate}
End If
On: Speed 1
End IF

IF ('time' is "8:01 AM") AND ("Speed 1 is on" OR "quick clean" is on") THEN
If ("quick clean is on") THEN
Off: quick clean
Wait for 1 second {gives zwave time to communicate}
End If
IF ("speed 1 is on") THEN
Off Speed 1
Wait for 1 second {give zway time to interact}
End IF
On Speed 2
End IF


Problably more complicated than wanted but the nice thing about the Rule Machine is you can have it check many different tondistions and respond accordingly. In this rule, the switches will not even send out if they do not need to. {Can also use the switch that is something like only if condition needs changing in place of the internal IF Then statements.)

Download the Hubitat app