Does a virtual switch with a neutral position exist?

I'm thinking of an on/neutral/off switch as a workaround to control my chromecast TVs using Assistant relay. The TV won't be able update the virtual switch but I'd like to have an on/off option to turn the TV on or off regardless of if the TV is physically on or off.

For example, pressing "on" on the virtual switch would send a command to Assistant relay to turn the TV on and then the switch would return to neutral position, instead of saying On.

Is there already a driver like this out there? It can probably be accomplished with two virtual buttons but I just thought I'd put the dream out there.

Not as a "Switch", because by definition a Switch has a single attribute that is either "on" or "off". If you had a virtual device with another capability, say "actuator", it could have a neutral value for some other attribute, and a command to set it to "neutral". But that won't work for a "switch". You can have a virtual device automatically turn to off after a settable delay -- but that would only help if "off" has no other meaning/use.

This other type of device, an actuator, could have commands "on", "neutral", and "off". But it could not have capability "Switch" at the same time, as that would overtake those commands and always be on or off. This might work, but it wouldn't be recognizable as a switch, so I don't see how you could select it.

You might be able to fake it with a dimmer. 0-50-99

Or, write a driver for such a device.

1 Like

Have two virtual switches both of which have "auto off" turned on. Use one virtual switch to turn your TV on, and the other to turn your TV off.

4 Likes

Where is the actuator device and is the code available for potential customization?

I could already get a similar thing with two buttons as well, but I'd like to keep it using one device per TV if possible because otherwise that'd be two devices per TV. If it's not possible I'll probably just abandon the idea.

Kinda sucks chromecast doesn't have power control outside of voice commands.

I'm not sure what the penalty of having two devices is; after all, virtual devices are free. :smiley:

I'd like for it to be available in the Google Home app as well.

Still not seeing the penalty. You'll have two momentary switches seen in Google Home or Alexa. For instance, once called "TV on" and the other called "TV off".

1 Like

Aesthetics and simplicity. I don't want my Google Home device list to be cluttered and I want it to be easily accessible for those in the household without having to pull out the Smart Home Manual.

2 Likes

Seems perfect at first glance, I'll look into it. Thanks :slight_smile:

I'm curious - does Google Home support "actuator" devices? I know Alexa does not.

I don't think so.

I was going to suggest he could use the Community Google Home app to arbitrarily assign On/Off to Actuator commands. But then I remembered it still needs to be either On or Off in Google Home. It can't be not both. In fact, he couldn't even do buttons in Google Home. The Home app UI is annoyingly limited compared to what the Nest Hub UI can do.

1 Like

I guess I'm not seeing the sense of a neutral in your example above. If you press the button to turn it on, why does it matter if it's in a neutral position? At that point the tv would be on. If it didn't send the on command correctly you could simply add a check state in the rule to repeat the function till you see it on (or off)

2 Likes

I was sitting here watching this thread and thinking the same thing. What am I missing here? If the state of the switch is wrong anyway (the Chromecast app cannot read/set the switch state?) then just flip on for on, and off for off and ignore where it is now...

2 Likes

My thoughts as well..

Yeah, I'm not sure the generic "Actuator" will work as expect (which Bruce also warned of). Google Home can't execute arbitrary commands on the device; they'd have to be standard capability commands and ones for a supported capability of device at that, at which point you're back to "Switch" with its "on" and "off" commands (and the "switch" attribute that only reports one of those two states). You could write a virtual switch driver that always generates "switch: on" or "switch: off" events when the on() or off() command is run, regardless of the current state (I'm pretty sure the built-in driver uses the default filtering-out of these events so you don't get them), which may help if there's a rule or something you want to trigger by voice.

However, for a Dashboard, this would likely still be a problem since the switch would be in one state or the other and you can't make it send an "on" when it's already on without getting it to be considered off first. Or, at least this is how Hubitat Dashboard works (but likely also any solution that tries to be user-friendly). But again, if voice is the main concern--and I'm not sure it is--an "always generate an event" kind of driver should work (unless the voice assistant tries to be super-smart and "optimize" things by not sending a command at all if it thinks the device is already in the desired state; not sure GH or Alexa do this, as far as I can see).

But if it were me, I'd probably use a virtual "momentary" switch to toggle (effectively a button, except I don't think any voice integration supports those at the moment--so this is a workarounsd for that) or two switches, one each for on and off. :slight_smile: Both suggested above. (I know, I know, one more device...)

1 Like

The TV power wouldn't be accessible unless I use a smart plug or something. So, if I turn it on within Google Home the icon would say "On" but then if I turn it off with a remote, that status wouldn't update and couldn't be updated. So I'm wanting it to return to a third state so the state within the app doesn't matter and I can just press on or off and it'll turn the TV on or off through Assistant relay. I was wanting to avoid the icon showing off when it's actually on or vice versa.

If I just had a virtual switch that would ignore the actual state, would that still come up as changing if I press off and the virtual switch is off?

Native remote or like a harmrony?