Preferred Way to Control Switch States as a Function of Mode

New to Hubitat, migrated from SmartThings and very much like the local execution and the Hubitat platform.

Wondering what the optimal approach would be in Hubitat to emulate what one could use a “switch” or “case” statement to do in WC. I had several pistons that tested the Mode variable to dispatch to the code blocks in the switch, executing specific device commands (e.g., turn on, off, dim selected lights and switches) for each Mode.

Simple example is Christmas Tree Lighting:

  • Day - switch on
  • Evening - switch on
  • Away - switch off
  • Asleep - switch off
  • Dawn - switch on

It appears one can accomplish this in many ways, several Simple Lighting Rules, a few RM triggered rules, maybe the Mode Lighting app (although it seems specifying a switch off is not supported by Mode).

Any advice as to the cleanest way to accomplish this in Hubitat would be appreciated.

Have a look at ‘Mode Switch’ (part of Cobra Apps)

This app can switch on/off set lights dim level etc on any mode change
You can also use it almost the same as an ST routine.
I use it to turn off lights etc for my ‘night’ mode amongst other things

Andy

Thanks Cobra, I will investigate that.

Just to help me understand the platform features better, what built-in approach would be the recommended way to configure the “switch” statement equivalent?

There isn't really an equivalent app to Mode Switch (that's why I created it)
Probably the best way to do what you want with in-built apps would be Rule Machine, using the mode as a trigger.
this will probably take several rules but I'm not the best person to advise as I don't use RM much
(Actually just one rule to 'refresh' L360 and I'll probably write something to replace that at some point)
BTW
Cobra Apps has a new home... http://hubitat.uk

I'm sure someone will be along soon to advise you better :slight_smile:

Andy

If using RM, I would do a rule as follows:

Rule: mode is any of Day, Evening, Dawn
When True: turn light on
When False: turn light off

There's really no equivalent of a switch/case statement, so if you need to do something more complex than a true/false type test it will involve more RM apps. Just depends on exactly how you want it to work.

**edit meant to reply to OP, not you you directly @Cobra, sorry about that

1 Like

See...
I told you so :slight_smile:

1 Like

Thanks all!