First Nested IF-THENs

How does this look, I want to verify that I nested everything correctly, Thank You :

IF (Time between 7:00 AM CDT and 9:00 PM CDT(T) [TRUE]) THEN
IF (Temperature of Tristen Motion Sensor(76.21) is >= 75.0(T) AND
Tristen Motion Sensor active(F) [FALSE]) THEN
Dim: Tristen Fan: 100
ELSE-IF (Temperature of Tristen Motion Sensor(76.21) is < 75.0(F) [FALSE]) THEN
Off: Tristen Fan
ELSE-IF (Tristen Motion Sensor inactive(T) [TRUE]) THEN
Delay 0:05:00
Off: Tristen Fan
END-IF
END-IF
IF (Time between 9:00 PM CDT and 7:00 AM CDT(F) [FALSE]) THEN
IF (Temperature of Tristen Motion Sensor(76.21) is >= 75.0(T) [TRUE]) THEN
Dim: Tristen Fan: 100
ELSE-IF (Temperature of Tristen Motion Sensor(76.21) is < 75.0(F) [FALSE]) THEN
Off: Tristen Fan
END-IF
END-IF
IF (Temperature of Tristen Motion Sensor(76.21) is >= 80.0(F) [FALSE]) THEN
Dim: Tristen Fan: 100
END-IF

Okay, I'm very confused. Why do you have different actions for day and night when the actions are the same? This would be a lot simpler if you removed the time part, since the actions are the exact same. Also, you have no cancel for the delay in the last else-if turning it off with no motion, which you should have at the top. So, the fan would Turn off after turning on, even if motion was active. I would try something like this.

Simplified If ( If motion active -> Cancel Delayed actions)
If Temp >= 80
         Fan On
Else If Temp >= 75&( (Motion Active and Time Between) or Time Night)
          Fan on.
Else If  Temp <75
          Fan Off 
Else If (Motion Inactive and Time Day)
         Delay + Cancel
         Fan Off
END-IF

Your triggers would have to be temp and Motion. You'll notice though, if you turn it off by hand and the temp goes up it will turn on again.

During the day you need motion and temp to trigger the fans and at night only temp because little motion happens while sleeping.

Okay...but that means if the time is night and you're not home, it will still turn on the fan. You might want to consider doing it by mode.

Ah good point, maybe I can just add an "AND" Home Mode for the night portion. I appreciate it.

Silly question-- where do you input if/then rules? I don't see a place to add such logic to Rule Machine 3 nor 4. What did I miss?

It's under the action of "conditional action".

Thanks!

1 Like

I simplified some fan_state=f(temp) rules with IF-Then-Else statements. While clunky, I can appreciate why the options are constrained to valid choices to drive the logic and avoid programming errors. Immediately, I don't have any suggestions how to improve it, so that is nice.

That said, is there a text file somewhere I can edit to build Rule Machine 4 rules at the command line instead of via the GUI?

1 Like

Another voice in the chorus.

I spent about an hour last night writing a simple rule -- truly easy logic that would have been less than 5 minutes in bash/perl/python/awk, etc. The interface in the GUI makes it very easy for me to make mistakes (ie., appending each rule to the end of the conditional because the "place after" dropbox is not persistent) and very difficult to edit rules (ie., you can't change a simple conditional to complex, cannot re-order actions, etc).

I have gone through a few weeks of evaluating the Hubitat. I think it is great, but would simply take too long to program everything by GUI without being able to copy/paste logic as described herein or to replicate room remotes as described in another post I made. I have a few things working, but have hit that point of 'not worth it' to program the whole house, so I sort of feel like I am waiting for 'the year of the Linux desktop' to finally hit with regard to a home automation solution that is worth doing.

I keep falling back to 'I am really glad I built out the whole house in Caseta because it is ultra reliable and maintenance free'. But the next step of Hubitat automation is just too time intensive in the GUI. I have a few remotes with cool logic working but a single remote takes 20 mins to click through the programming.

So far my best idea is to hire a neighborhood kid to do it which might give some experience of programming logic to somebody that might benefit from it.

Maybe Hubitat could have a 'developer' program which allows CLI access along with agreement that if I break it, that's my fault and problem. Otherwise I think my next step is to take it apart and look for anything obvious in circuit layout (JTAG connector etc. but I doubt it) before tossing in my barrel of parts that might be useful one day.

I really like the Hubitat, which is the first HA system I have tried that I do actually like the supporting logic. it is just too inefficient for programming whole-house control as a GUI-only driven device that cannot replicate remotes as far as I can tell. I wish I would have caught that earlier.

May be off here but are you asking to be able to "clone" your button remote device? If yes this is already in you need to select rule to clone.

I have loads of button controller rules that are essentially the same for each room so I just clone them and edit the bits.

Yep thanks. I was distracted by using Button Controller instead of Rule Machine. This looks like the way to go.

1 Like

Button controllers UI is now within RM and with that comes loads of extras so button controller on its own is kind of redundant and I don't believe it's being worked on any longer. It is obviously getting updates within RM though :+1::smile:.

Make sure you select "button device" to get the correct UI