Hello everyone. I've been running a rule for a while now. It activates the washroom fan when there is high humidity (someone showering) in the washroom. Most of the time it works, sometimes it fails. I'm thinking that I don't have it set up in the most efficient way possible. Can I get some opinions on this? How would you do it?
You for sure don't want to re-trigger the rule when the fan turns on. So it should not have the second trigger.
I'd approach this slightly differently. I'd use a single Conditional Trigger, like this:
Humidity of Ensuite Humidity/Temperature reports increased by over 5 ONLY IF(Humidity of Ensuite Humidity/Temperature > 90)
That trigger will only fire when the humidity rises above 90 and we avoid re-triggers on each humidity report. Then for actions, it's simpler:
IF(Humidity of Ensuite Humidity/Temperature <= Hallway Motion) Exit Rule
On: Ensuite Exhaust Fan
Wait for Condition: Ensuite Humidity/Temperature < 86
Wait for Event: Elapsed Time 5:00
Off: Ensuite Exhaust Fan
In a sense the Wait for Condition is a second trigger, replacing your second trigger. Also, there is no reason to trigger on every increase or decrease, because something only happens when the humidity exceeds 90 (or falls below 86). By using the Waits, this allows the rule to basically start over should the humidity rise before the fan turns off (the Waits would be cancelled by the new trigger).
Not gonna impact the running of the rule but be sure to use END-IF’s for each IF statement. You should have 2 at the end of that rule to keep it clean.
I have wanted to mention I think RM should give an indication if a END-if is missing. You are right in most cases it doesn't matter, but I just went through this with an embedded end-if. I made a change to a rule and didn't notice until a few days later it wasn't working.
At first I could not figure out what was going on, as it was a minor change. After staring at it for a minute I realized that the indentation was off and realized I had missed adding a END-IF.
Not sure how difficult that would be, but a broken rule indicator for a rule that does not have a end-if for each if could be helpful.
All that to say it's a good idea to get in the habitat of doing that.
The UI is putting up ENDIF in a box at the bottom of the Actions table, so it's sort of in your face already when ENDIF is needed. There is no way to tell at any point while defining the actions if there is a missing ENDIF or not, beyond showing that. A missing ENDIF doesn't equate necessarily to a broken rule, nor does it even equate necessarily to a broken action.
Hey folks, here's another one. I’m looking for some advice on a rule I’ve set up that feels like I may have overcomplicated it. I’d love if someone could take a look and suggest any ways to make it more efficient.
Here’s the scenario:
I have a towel warmer connected to a Zigbee plug. The towel warmer must be manually turned on, and when the power is cut (e.g., by toggling the plug), it turns off. When the power is restored, the warmer defaults to the OFF state.
The current rule works like this:
1. I manually turn on the towel warmer. (on the warmer itself)
2. The Zigbee plug detects current running through it and starts a timer.
3. After 2 hours, the Zigbee plug toggles OFF/ON to turn the towel warmer off.
4. Additionally, there’s a visual indicator triggered on another device to show whether the towel warmer is on or off.
It works, but I can’t help thinking I’ve over-engineered this. Any feedback or ideas for improvement would be greatly appreciated! Screenshot of the rule is attached.
I'm late to the party on this, but there is a great app that I've been using for a couple of years in HPM that controls bathroom humidity fans. It can be used with just 1 humidity sensor, but can also configured to compare 2 different humidity sensors (e.g. one in the bathroom and one outside the bathroom).
Once the power level of the Towel Warmer goes above 2, does it fluctuate at values above 2 over the next 2 hours? If it does, then the first part of the IF is going to re-run every time the power level changes, and it will start another 2 hour delay each time.
Assuming it runs for two hours and the power reports every 1 minute with a different number above 2, then at the end of the 2 hours there will be 120 scheduled delays. You're canceling those once the power drops to zero, but having all those extra delays scheduled seems like a messy way to do it.
I'm also not clear on why you have the On command in both the IF and the ELSE-IF actions. Does the switch report power 0 when you send it the Off command? If so, it seems like the ELSE-IF actions would run and turn the switch back on before your 1 minute delay. Either way, it seems like you're sending the On command twice at the end of the two hours, and I'm not clear on why you need the redundancy.
I would use a Private Boolean to prevent re-triggering and split this into two rules to clean this up.
Rule 1:
Required expression: Private Boolean is true
Trigger: Power level reports > 2
Actions:
Set Private Boolean false
Set indicators for On state
Delay 2 hours (cancelable)
Turn off Towel Warmer
Rule 2:
Trigger: Towel Warmer turns Off (or Power level = 0 if it makes a difference)
Actions:
delay 1 minute
Set Private Boolean true on rule 1
Cancel delayed actions on rule 1*
set indicators for Off state
turn on Towel Warmer
*The "cancel delayed actions on Rule 1" is only needed in the event you manually turn off the Towel Warmer switch early, because otherwise those actions should have already run, since the last action of Rule 1 is what triggers Rule 2.
It does fluctuate. It gets itself top temp, cuts, power, applies power again, and so on. Kind of like a toaster oven that maintains a certain temperature. (this is what makes this a little complex)
So why the On command. Because cutting power to the towel warmer, and then applying power again essentially acts as an Off switch, We turn the towel warmer on manually when we use it, so it needs power all the time.
As for the redundancy, I think I had that set up in case we turned off the tower warmer manually. Now that I'm typing this, I'm thinking I should have one rule for the indicator, and one for the on/off functions.