How to achieve these conditions

I am nearly finished with creating the simple rules for most of my devices and have started working on converting some of them into more complex rules as I can't achieve what I want to do with the Simple rules.
I am stuck with some of them so wondering if someone can help me with how I can achieve it.
Here are a couple of examples.
Turn on shower exhaust fan when the temperature is above 22 degrees (warm weather) and there is motion and humidity is above 80% until it goes below 70% or 20mins whichever is earlier. Do not turn it on if the temperature is below 22 degrees and there is motion even if the above conditions are met. In this case turn it on when there is no motion.
To put it in simple words, I want the exhaust fan to be turned on in summer when I am in the shower but in winter only when I am out of the shower.

Another one is similar but for the exhaust fan in the toilet.
Turn on toilet exhaust fan when the temperature is above 22 degrees and there is motion. When the temperature is below 22 degrees and there is motion, turn it on every 3 mins for 1 min.

Edit: There is another one.
When Chromecast is playing, set TV Lightstrip and couch Lightstrip to certain colour and brightness and turn off room lights

Thanks in advance.

I would choose some different thresholds myself, but that's not what we are trying to achieve here.... Here's my suggestion, but I am cheating and not including the "or humidity drops below 70" option, thinking the difference there is probably not worth worrying about...? I feel like there will be holes in this setup, that could be a self-confidence thing, but I'm sure there would be situations it won't handle, would just need to mull it over a bit more... Certainly worth starting with (I think) and then adjusting as you go...

Summer Rule

Predicates
Temp >= 22
AND
Humidity >= 80%

Trigger:
Motion detected

Actions:
Turn on the fan
Wait for 20 minutes
Turn the fan off

Winter Rule

Predicates
Temp < 22
AND
Humidity >= 80%

Trigger:
Motion becomes inactive

Actions:
Turn on the fan
Wait for 20 minutes
Turn the fan off

Well, the good and bad news is there are a million ways to do what you are asking.

Similar to @sburke781 above, Iā€™d personally create multiple rules for each use case.

I know a lot of people who prefer to have the fewest rules possible (used to be me) but I find itā€™s much simpler to maintain and update complex stuff like this via handful of smaller, more manageable rules.

Since all the rules you mention share the same base temperature ranges, I would personally start by creating a custom variable (Boolean/Switch) just to help keep track of Summer/Winter then use that single variable as a predicate across multiple rules.

For example, Iā€™d write a simple rule so when temp > 22 the variable = true (for summer), else set to false (for winter).

Next I would write a rule for shower fan summer, shower fan winter, toilet fan summer, toilet fan winter.

An example of something like toilet fan winter could be something like:

Predicate:
variableSummer = false
(or variable connector switch = off)

Trigger:
toiletMotion = active

Action:
On: toiletExhauastFan
Cancel Delayed Actions
Wait for event: toiletMotion = inactive
Off: toiletExhaustFan - ->
Delayed: 0:01:00 (cancelable)

Once I confirmed the Winter version worked Iā€™d copy the rule then edit the predicate and update the action for Summer and then move on to the shower fan scenario.

One of the other advantages of having a single rule to toggle the Summer/Winter variable is if you decide later 22 degrees is too hot or cold, you only have to update the number once here, instead of having to update the temp within multiple conditional statements across a handful of rules.

1 Like

I guess the problem I have with some of the logic is the potential for different behaviour that is not expected or event wanted.... But it's not my call.... The kind of thing I am thinking of is behaviour between night and day during shoulder months where the temperature may fluctuate from day to night. Can still be manged, might just need some extra conditions per mode, etc.

Certainly with the toilet fan rule (and maybe even the shower rule(s) ), one option may be detecting the fan being turned on manually and turning off after a period of time, just as a start.

I certainly agree with breaking this up in to a more manageable set of rules, rather than one larger, more complex rule. Even just setting up part of what you want to achieve, rather than targeting the final setup you are after.

Simon

Yea I like where your head is at, I was thinking the same thing but did not want to scare you with information overload.

Mode manager is probably the simplest way to manage day/night.

I personally use the lux reading from an outdoor motion/light sensor to toggle a variable similar to the summer winter example above. I use that single day/night variable as a predicate for a ton of my other rules.

1 Like

This is the only the starting point and I am going to play with different values until I am happy with it.

I will give it a go. What if there is a cold morning and warm evening, which we have in spring and autumn, will it still work.

1 Like

I may not end up with the same final ranges but I can create separate custom variable for each if I have to. I am new to RM and haven't used the Boolean yet so will read about it.

Can you give some examples of where you use this.

That makes sense. Good idea...

Will have to think that one over, I'll get back to you on that... Or anyone else can jump in :slight_smile:

As much as I am probably avoiding the difficult issue of speculating whether logic will work, I am thinking it may be one of those holes that you need to find as you use the rule, rather than labour the what-if's. You are right that, on the surface, I expect it may be an issue, but it will probably end up being living and working with it that will yield the most valuable insights into how much of an issue it will be and whether it is worth working through.

Take the plunge... Just make sure you have an easy / convenient way to turn the fan on manually for days where the rules doesn't work.

Now that I say that, one suggestion would be to include a predicate or something similar to allow for a manual override. I have them in most rooms for my motion-based lighting rules. If I initiate a manual adjustment to lighting in any way, such as use of a Hue dimmer or similar, then the motion lighting is disabled until I use a similar manual method to turn the lights off. Not simple to setup to begin with, but something to keep in mind.

Simon

Sorry for the late reply, I forgot you had asked me for an example! So here is a high-level of how I use lux values and variables to trigger a few automationsā€¦

First off, I have an Outdoor Hue Motion sensor on the side of my house that captures Lux. I monitored it for a week or two and kept mental note of the value whenever it looked dark enough outside that Iā€™d want my porch lights on/off.

Eventually I created a numeric variable to store that lux value.

Next I created a rule that looks for changes in the outdoor lux every ~30 mins and compares it to my lux variable. If the current lux is darker than the variable then I know itā€™s dark outside, if itā€™s higher than my variable I know itā€™s bright outside.

I use this info to toggle a virtual switch (Boolean variable) to ā€œonā€ when itā€™s bright and ā€œoffā€ when itā€™s dark out.

Separately, between 6am and 8pm I have a rule that is triggered by the virtual light/dark switch so regardless of ā€œsunriseā€ or ā€œsunsetā€, if itā€™s dark outside (because of heavy rain perhaps) my outdoor lights turn on and if it brightens later the same afternoon (because rain clears) the outdoor lights turn back off.

I also use the state of this virtual light/dark switch as a predicate for many of my motion sensors rules. This way certain motion sensors both inside and outside only turn the lights on if itā€™s dark outside avoiding lights turning on for motion during the day when they do not need to be but more so, if it is dark enough outside in the middle of the afternoon and motion is detectedā€¦ the rule knows to add light instead of simply being time-bound to only work at night like I used to have them all.

Admittedly I went through 3-4 number values (at least) for my initial lux variable the first few weeks which is really where that first variable came in handy - as I only needed to update the value in this one variable whenever it seemed too dark/bright and all the half-dozen connected rules linked to this variable or the light/dark switch it defined would also be adjusted accordingly.

Does that help at all?