Can I use rule machine to make a single button do different things based on the status of the controlled item? Specifically asking about shade control

I just installed my two new cell shades from zebra blinds. I have a aqara wireless mini switch which is a single button. I have two blinds in my room. I would like to find a way in rule machine that when a single press is done on the remote the blind, will either open or close based on its current state. So if the blind is currently open doing a quick push will close the blinds. If the blind is closed, doing a quick push will open the blinds. And then I'd like to repeat the process for double click for the other blind. Is it possible to have the same button click do different things based on the status of the shade?

Yes. What you want in Rule Machine are conditional actions. Create a new rule and use "Button Device" (not "Button") as the trigger. You'll then get separate actions sections for each possible button event. In the appropriate actions section, you can do something like:

IF (Blind is open) THEN
  Close Blind 
ELSE
  Open Blind
END-IF
1 Like

Thanks! Can I compare two blinds?

IF (Blind1 AND Blind2 is open) THEN
Close Blind1 AND Blind2
ELSE
Open Blind1 AND Blind2
END-IF

Yes, you can make arbitrarily complex conditionals, and you can also choose for actions (like open/close) to affect more than one device.

I cannot figure out how to to do an IF-ELSE structure, but I was able to make multiple If conditional statements where only 1 can be true for a button push. Is there a way to do if-else conditions

I'm not sure what you mean with "true for a button push." If you are testing button attributes--event names or values--as part of a conditional in rule actions, that is not likely to work as you expect (it's possible to do but I can't think of a time when you'd actually want to do this); what you want instead is to choose the button event--for example, "button 1 pushed," as a trigger. The "Button Device" trigger makes this easy to do, as you'll get separate "Actions to run" sections for each possible button number/event your device can do. Do not use the similar-sounding "Button" trigger for this, as it works differently.

As for how to do IF and ELSE structures in rule actions, you can indeed do what you are asking for. The result will look almost exactly like I wrote above. Since the RM UI can take a bit of getting used to, it might be easier to watch a video if you aren't sure how to use it to create this result. Here's one where they create a conditional similar to what you'd want, though obviously with different conditions: Rule Machine 2: Advance Conditional Rules - YouTube. (But to summarize: you create conditional actions via the drop-downs in the UI the same as any other rule actions. They are under "Conditional actions" under "Select action type to add." I'm not sure what you've done so far but it sounds like you may have just created something under "Manage and create conditions," and in that case it should be noted that while you can create things here ahead of time to make it easier later, they do not actually do anything unless you use them somewhere in your rule--i.e., in a conditional action.)

Thank you. I was just starting to google and look for some videos. I will read up some more. I think I am on the right track. This is what I have so far

That looks like a good start! (You didn't make the mistake I warned about above; you correctly chose the "Button Device" trigger.) As you'll see in that video, in your case I'd probably recommend avoiding the "Simple conditional action" type and just using the full "Conditional action."

A simple conditional more or less just saves a few clicks at the expensive of only letting you use one condition and one action--both limitations that "full" conditional doesn't have, as you'll probably see in the video. In other words:

IF (X is Z) Do Y

is a simple conditional equivalent in outcome to

IF (X is Z) THEN
  Do Y
END-IF

with the biggest difference being that the latter gives you more flexibility now or later if you want to make the condition more complex or perform more than one action (or add an ELSE, ELSE-IF, etc.).

1 Like

Got it!

IF (Jennings Left Shade windowShade(closed) closed(T) [TRUE]) THEN
Raise Shades: Jennings Left Shade
ELSE-IF (Jennings Left Shade windowShade(closed) open(F) [FALSE]) THEN
Lower Shades: Jennings Left Shade
ELSE
Lower Shades: Jennings Left Shade
END-IF

Thank you!

2 Likes

That should work! If you wanted to save a few clicks, it looks like you should also be able to leave out that ELSE-IF and the result would be the same (since you're lowering the shades in any case besides the one in which they already report closed)--unless there's something I'm missing. There would be no difference in outcome, however, so I probably wouldn't bother with it at this point (and the above does give the advantage that adding different actions in these different cases, should you want to do so in the future, will be easier).

That's a good point. I went to test and the dang aqara remote has fallen off the network. I have a poor zigbee mesh. I need some repeaters.

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