Virtual switch exposed to Google home

Hello,

I am looking for good method to expose to Google home couple of switches that execute node-red automations.
Is there any method to create “virtual” switch that is doing nothing beside being able to trigger node-red automation? I’d like to control some of my non-smart devices via node-red and IR blaster. I tried input_booleans but it doesn’t work for me because if I turn off device manually, input_boolean keeps “ON” state and I can’t trigger it via Google assistant. I tried also with command_line switches, but I can’t get those working with google home- Node-red triggers only if I switch them via home assistant.
I don’t need actual state of device to be visible in home assistant, I just need switch that let me assign google home “turn on…” and “turn off…” commands to my node-red.

u can use a switch template where the turn on and turn off actions are defined by yourself like turning on/off an input boolean. i use this to control my devices connected by IR I only control them via automation or voice so the state is always known :slight_smile:

Input Boolean or MQTT switch

As I said, input_boolean is not working in my case, because I have no possibility to update its state after turning off device manually and since input_boolean is still ON in home assistant, Node-red is not reacting to Google’s command “turn on xxx”.
I’ll try with MQTT if it makes any difference. Basically I need switch that is somehow exposed as on-off switch to google home, but is resetting to “0” value (ON-0-OFF), so Node-red detects state change to ON everytime I use google assistant, no matter in what state device is.
Maybe I’m dumb and there is easier way to achive it?

You need a way to get state then in order for anything to know if it is on or off. You can use input booleans or MQTT switches and force them back to a default setting, using Node Red.

why not just use a script so it executes no matter what? you probably will need 2 scripts one for turn on and one for turn off. then expose those scripts and each one will execute as needed.

Hello
Piramidowy, I have just read your question. I immediately remembered “Nora”. With “Nora” you can set up a “dummy” in NodeRED which will then be displayed as a switch or scene in the Google Assistant. Since you have NodeRED in use, it is a simple HA to connect with Google Assistant and create and control dummy switches. In HA, for example, an “MQTT switch” is created that triggers a “Nora switch” in NodeRED. You can also start this flow via Google Assistant and HA will change the status of the switch accordingly. Have a look at the following link:

https://discourse.nodered.org/t/node-red-google-home-integration/4829

In Google “Home”, “Nora” can be added …

In NodeRED this must be installed and set up:

https://flows.nodered.org/node/node-red-contrib-nora

maybe I could help you …
greetings

If the only problem with the input_boolean is that it doesn’t turn OFF again… why not just set up an automation that, once it’s turned on, after a second or 5, it turns it back off. Then it’ll always be off for when you shout at google.

@dshokouhi, Scripts are working fine, but I’d have to say “activate …” instead of " turn on/off …". I’d prefer on/off command.

@VolkerKa, this is interesting. I’ll look into this. Thank you!

@swiftlyfalling, unfortunatelly it’s the same situation with OFF command. I gave example with ON, but it’s the same both ways.

If you set up the Google routine as ‘When I say…’ you can say on or off to run a script.

For example, I have a script that turns on my TV to the news channel and I say ‘Turn on the news’.