Moving from WebCore to Rule Machine help with 2 rules

Totally new to Hubitat, and I was never terribly good with WebCore. Bar 1 Iris repeater I've gotten all my devices set up, and most of my rules recreated (still a bit unsure on some pico remote setup, or optimal mode/lighting automations, but I can probably figure those out). I do however have two rules that are quite important to be working right for WAF and not flooding my downstairs neighbors, and I'm lost on one and not sure I've gotten the other right. I've included both their WebCore versions and my attempt at recreating one in Rule Machine.

The goals are to automate both 1 what happens when my shower turns on/off, and 2, to ensure that it never stays on for over 30m with no motion, or an hour with motion detected.

I've tried to create a rule for the former, though I'm not positive it lines up with the WebCore rule I had had, and the latter I got lost at the very first step.

I'd really appreciate any help, thanks!

49%20PM 53%20PM

The first problem that you have, your trigger is for the valve being open. That means that anything to do with the valve being closed will never execute. Your trigger needs to be changed to CHANGED.

Also, your conditional actions are structured incorrectly. You want to have something like this:

TRIGGER:  Value Changed


If Valve is open:
     Cancel Delayed Actions
     Fade your lights up
     If temp is X turn on heater (use the simplied conditional action for this, not the regular conditional action)
     Delay actions by 30 minutes (cancelable)
     Close Value
     Cancel Delay actions
     Delay actions by 3 minutes (cancelable)
     Set lights the way you want.  (a little advice, take out all the waits and just set the lights, you'll make youself a lot happier.  Playing with all those waits and cancels is going to a nightmare.)

A little advice, since you are canceling your delayed actions in both if and else, do not use any delayed actions but instead use separate actions of delay. Delayed actions get scheduled at the top of the rule. So, it's possible that a subsequent cancel will cancel the delay you just scheduled.

I'm a keep it simple person and break this into multiple rules.

  1. Shower valve and exhaust control
  2. Heater control

1a.Shower valve 60 min

	shower valve changed
	If shower valve on
		Turn off shower delayed 60 min cancelable.
		Exhaust on
		Light on
		Cancel delayed actions
		Exhaust off
		Light off
		Heater off
	End if

1b. Shower valve 30.

	Valve changed
	Motion changed
	If valve off
		Cancel delayed action
		Exit rule
	End if
	If motion active
		Cancel delayed action
		Valve off delayed 30 cancelable
	End if
  1. Heater control:

    Trigger: valve changed
    Temp changed
    If valve closed exit rule
    If temp<67 then
    Heater on
    Heater off
    End if

Nothing like a pandemic to really get one going on automations. Thank you guys for the help.

I think I'm getting greater rule machine facility, but it's definitely still limited.

I separated out the 30 and 60 minute cutoffs and I believe they're working appropriately. I'm trying to fix the on/off automation which is controlling the exhaust fan/heater/lights in relation to the shower status. I think I have the timings right, but I'm definitely not sure if I'm using delays or cancellable right, and I'm having trouble with the final ELSE-IF, which I don't want to be dependent on the heater being on.

If it isn't clear the goal is:
When the shower comes on the shower light fades to 100, the fan kicks on, and if the temp is low the heater turns on.
When the shower comes off the inverse heater and fan turn off, the shower light fades down, and the overhead and mirror light fade up.

The delays are all aimed less so at me/a desire to overcomplicate things, and more at guiding timing for anyone else. They roughly correspond to water heating up, steam clearing, and the floor mats not getting soaked.

Any more assistance would be truly grand.

Screen Shot 2020-03-29 at 4.34.56 PM

Your else-if is in the wrong place because you have to insert an END-IF before the Else-IF. Right now your else-IF is an else to the temp of the motion sensor and not to the valve being open. YOu see how they're on different indentation levels?

Oh absolutely. I understood what was wrong, but not the resolution. Is this formatted correctly?
Screen Shot 2020-03-29 at 5.46.40 PM

Well, #1 you're missing an END-IF at the end of the rule actions. #2, you don't have any cancels anywhere in your rule, so why are the delayed actions cancelable? I would think you would want to fade up the shower lights as soon as you turned the shower on, not 30 seconds later. And you are fading them up over a minute. So, the lights won't be on for 1:30 after you turn the shower on?

You either need to put in some cancels right after your first IF and the ELSE-IF or you're going to get some wacky outcomes when you turn it on and off quickly.

You also don't need a ELSE IF you can just have a else. As the shower is only OPEN or CLOSED if it's not OPEN it must be CLOSED.

End-if is the easy one, so that's just throwing one more end-if but at the end of the rule? I'm processing that as being similar to a close paren?

Frankly I don't have the foggiest the appropriate cancel structures. That's one of the big things I need help with. Do I understand right that the issue is basically that if cycled quickly the on automation will still be running when the off begins?

The timing is what I'm aiming for as a bit of UX design for the less techy, less invested bathroom users. The shower takes a good 2 minutes to get warm, so the lights are serving as an indicator of how great an idea stepping in the shower right away is. Fan has the delay for the associated reason of indication and because it's only useful when steam is an issue, and that's not an issue till at least that point.

But if you want to leave it, it's not wrong. I might not have caught that your ELSE-IF was in the wrong place if it was just an ELSE. Personally, until you get a better handle on RM, I would stick to else-if.

Just add the two "Cancel delayed Actions" in the two places I mentioned....after the very first if and after your else-if. Then you should be good to go.


As it comes to else-if, is the distinction there that else-if is useful for more complicated expressions that aren't based on a binary condition, but there're a range of potential options?

To edit it here would require recreating the actions under it as well, right?

1 Like

Else happens whenever your IF or any previous ELSE-IFs don't happen. So, if your IF only has 2 possible permutations, ELSE is "safe" because it can only be two ways. But if your IF is complex with many different reasons it could be false, you might not want your ELSE to fire every time the IF is false. That's when you use ELSE=IF.

Look at it this way....ELSE IF will never be wrong. But ELSE could be.

Gotcha. In that case the else-if provides the specific if that makes it the case.

Yup....and you can have multiple ELSE-IFs but only 1 ELSE. So, it would go something like this:

IF (A B and C true) THEN
     Do X
ELSE IF(B and C true THEN
    Do Y
   Do Z
   Do A

I agree and in this simple rule it's not going to make much difference. But it good information to know.

Yeah. With this it wouldn't make much difference but on a larger rule with maybe nested IFs, it's a test that wouldn't be needed, so by using ELSE it makes it slightly more efficient.

Rule looks good. How do you plan to turn off your mirror light?

Currently there's an imperfect smart or motion lighting automation that shuts off the lights. I don't know how I would functionally put a mirror light off in this since I think it's out of the range of there being one obvious workflow upon shower exit. The fan etc are all tied to the shower itself and don't really vary much, the mirror light is more because it makes the bathroom more inviting and realistically there's a high chance of mirror use. I'm always open to ideas though.

I also stupidly used Lifx bulbs (for the shower and overhead lights, everything else is Lutron Caseta) because I thought there might be a value in the color changes as temperature indicators or something, but in reality never figured out a way where that worked or was all that pleasant.

I bought a few RGB devices and I still barely use them. Unless you're going to go whole hog for RGB then it dosn't make a whole lot of sense. So don't feel bad, I have the same problem.

For sure. I understand it for accent use, or maybe some of the Hue integrations, but particularly in the bathroom it's been tough. There's no temp sensor with the shower, so the only way a temp connection could work would be really informally and time based. Otherwise there's maybe a benefit towards adjusting the white balance, but I've yet to really stumble on where that even matters that much.

The double whammy is because every other light switch is a Lutron dimmer or pico, the two Lifx really throw things off since even when controlled by a pico remote, there's just enough of a delay to confuse people who don't know what's involved.

1 Like

One last related question.

In conjunction with having automations for the fan/heater/shower, in Smartthings I had had auto cutoff rules for all three based on being on for half an hour with no motion in the room, or an hour without any motion.

I'm working on recreating that in rule machine and I think I get the format, but I'm not confident what the appropriate trigger would be. Is inactivity of the sensors right? Should the rule run based on the state of each device having changed? Is it functional to do all three as a rule or are three separate rules appropriate?