Switch to display if any device on and action on turn on

Hey guys,

Anyone have a way to make a virtual switch:

  1. Turn on if any of 6 devices is on
  2. Turn off if all the devices are off
  3. Turn on 1 of the 6 devices when switched on
  4. Turn off any of the 6 devices when turned off

In my specific instance, only 1 of the 6 devices can be turned on at a time (they are all Logitech activities and I'm using @ogiewon device driver) so that should make things easier.

The issue I have is if I program it in RM, if no activity (device) is on and I use the remote to turn on an activity, the virtual switch would turn on which would then turn on the 1 activity I had selected.

So basically, if the virtual switch is turned on via RM, I don't want it to turn on the 1 device. However, if it's turned on via any other means (Alexa, dashboard etc), then I want it to turn on the 1 device I selected.

Hope that makes sense.

Thanks

How will you determine which of the 6 to turn on?

Without that requirement, this is a hubitat Group. That is exactly what that app will do. If you add all the devices to a group, it can be set to indicate if any of the members are on and if all the members are off. Turning it off will turn off all the members. The one thing you cannot do is turn on a group device to turn on only one of the member. I don't see how you would be able to do that and your other requirements. You would have to turn on one of the 6 members.

It's predetermined. I only want to turn on 1 specific device of the 6 every time I turn the virtual switch on myself.

I definitely don't want to turn on all 6. That's why a group doesn't work in this instance.

Then you would have to write a custom app to be able to do this. If you removed that one requirement, your job would be done.

EDIT: Wait...you also want to turn off one if another turns on? That would also require custom code. This is a very, VERY complex set of requirements. Just starting to pull the threads together and I'm seeing at least 4 if not more rules would have to be written. And even then, timing is going to be very difficult.

Yeah, would wait to say if someone else has something like this already. That specific requirement is the most important so need it.

Seems like it'd be an easy app to write and could be a good way to get familiar with Groovy

Then I would go for it! That's what I did. I've slowly been moving anything that I want "special" like this over to custom, one-off apps. It's a lot easier to get EXACTLY what you want when you go right to the source! :slight_smile:

Nope, the devices are mutually exclusive by default i.e. only 1 can be on at a time, so I don't need to turn off any if another turns on (that automatically happens).

1 Like

Yeah, would wait first to see if anyone has a solution. Don't want to write custom code of I don't have to.

Wait...there is already logic in the devices themselves? Are these part of a parent/child relationship? If so, then it might be a LOT easier. You would have to use the parent device instead of a virtual one but it makes the coding so, so, SOOO much simpler. The linkage between the devices already exists. So, half the work of writing an app is already done in the drivers.

The Harmony Hub Integration already has a child device that handles most of what you're asking for... The "PowerOff" child devices indicates "on" if all of the other Activities are "off", and vice versa.

The one thing that is missing is a Default Activity if the "PowerOff" device is turned "off" (I know, the logic is reversed because of the name of this device.)

So, perhaps a simple enhancement to the Harmony Hub Parent Device to allow the user to select a "Default Device"....:thinking:

Yup, I'd want a child device that's the opposite of the power off though i.e. on when "power off" is off and vice-versa. And yup, a default activity when that child device is turned on (or "power off" is turned off like you said). That actually seems like a logical behavior for the parent device (if it was treated as a switch)

Ugh....I must need another cup of coffee. I didn't make the connection from Logitech to Harmony. :man_facepalming:

But yeah, that's much easier if there is already an established parent/child relationship between the devices since the communication between the two is built into the platform. I'm sure @ogiewon can sort you out.

1 Like

Yes, this is what I was thinking as well. If I add the Switch Capability directly to the Parent device, then if any Activity is "on" the Parent Device's switch attribute will be "on" as well. If all Activities are "off", the Parent Device's switch attribute will be "off" as well.

Then, add a user preference allowing the user to select one of the Activities as the Default. If you turn on the Parent, then that Default Activity is turned on.

How does this sound?

2 Likes

Sounds perfect. Thanks sir!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.