Broadlink IR + Google home on/off switch

Hi,
I have working setup of home assistant + google home + broadlink IR controling my stereo system. Currently, because my amplifier is using the same IR code for both, turning on and turning off, I’m using command "Hey google, turn on ‘amplifier’ to toggle it on/off.
However some of my other devics are is using different IR codes for turning on and off, so I would like google assistant to be able to react for both commands: “turn on XXX” and “turn off XXX”
Is it possible to create switch or script for broadlink, so google assistant can recognize not only “turn on” command but also “turn off”?

For broadlink switches I have config as below:

  amplifier:
    friendly_name: "AMP ON/OFF"
    command_on: 'XYZ'
    command_off: 'ZYX'

What make and model of amplifier?

The reason I ask is that there are published lists of discreet iR codes (on and off) for a lot of devices. You may be lucky and find discrete on and off codes for your amplifier.

Amplifier is Marantz PM6006. Unfortunately I couldn’t find separate codes for on/off. The only possibility I see is to use the same IR code for on and off command so Google assistant can’t react to both commands, but it’s more like toggle than real switch…

What modem remote control comes with that?

All of the following discrete power codes are worth testing:

Remote Model: RC-96SR

Marantz Receiver(1)

Marantz Receiver

More here: http://www.remotecentral.com/cgi-bin/codes/marantz/page-1/

Thank you. Unfortunately non of those codes work as a separate ‘off’ command. Guess I have to stick with toggle. Probably I’ll end up with power consumption-state detection.

Ok, back to your original question, it should be possible to use the same code for the ON and OFF commands.

Or your could create a command called ‘Toggle’.

Just put the same IR command for on and off in the broadlink switch

I’ve done that some time ago and it’s working. I must have messed up something with code originally.
About using same command for on and off- of course it’s working, but I can’t make automation to turn on amplifier + fm tuner as single google assistant command since it would turn off amplifier in case it’s already on.
As I said, probably I’ll end up sensing power consumption to recognize whether amp is on or off.

Can I ask a dumb question? I am very new to HA and any of these but I got myself started by buying all needed hardware. Eventually I will try to fully automate my house when I remodel it next year assuming I will be able to learn quite a bit here. However, my desired goal right now is to be able to control my TV completely by voice ( google assistant or Alexa). That means I can use commands like Hey Google, move down, move up, move right, move left, press OK, … instead of pressing buttons on the TV remote respectively. My idea is to map out all these voice commands to corresponding IR codes from the remote and ask HA system to tell IR hubs like Harmony or Broadlink to fire these IR codes.

Do you think it’s possible or know if anyone else has done this before? I search all over the Internet but couldn’t find any clue rather than preset Activities or Scenes which are nice but quite limited.

Thanks,

Yes, it is possible to map voice commands to IR codes via HA->switches/scripts->Broadlink. I have some of my TV remote buttons mapped to Google Assistant.
However I’m not sure if you can map command like “move down” or “press ok”, since Google Assistant recognize only commands as “turn on/off …” and “Activate …”. Proper way for me is to use command: “Activate move down”.
(For second part- I’ve heard that with google routines(?) you can define custom commands, so maybe it’s possible not to use “activate…”. I can’t test that atm, because Google Assistant is not supported natively in Poland and I don’t have access to routines. You should probably verify yourself.)

Part of my config responsible for Volume+/- is below. Google Assistant is reacting to commands “Activate volume up/down”

config:

  amp_vol_up:
    friendly_name: "AMP VOL+"
    command_on: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
  amp_vol_down:
    friendly_name: "AMP VOL-"
    command_on: 'xxxxx    xxxxxxxxxxxxxxxxxxxxxxx' 

  cloud:
    google_actions:
      filter:
        include_entities:
         - script.amp_vol_up
         - script.amp_vol_down
      entity_config:
        script.amp_vol_up:
          name: Volume up
          aliases:
           - Amplifier volume up
           - volume up
        script.amp_vol_down:
          name: Volume down
          aliases:
           - Amplifier volume down
           - volume down

script:

amp_vol_up:
  sequence:
    - service: switch.turn_on
      entity_id: switch.amp_vol_up
amp_vol_down:
  sequence:
    - service: switch.turn_on
      entity_id: switch.amp_vol_down

Hope it helps!

Thank you very much. Yes, definitely I have to use routines in Google Assistant to custom all voice commands to suit my needs. I also realize that Google Assistant has reserved some of the common voice commands for itself and google chromecast so I need to avoid those as well.

I’ll try that when I get all the parts next week. Now it’s time to learn some tricks.

Thanks to your suggestions, I was able to do what I want using Harmony Hub even though there’s quite a bit of annoying latency/delay between voice commands and final actions and Google Assistant doesn’t offer continuous conversation when you adjust the scenes (scripts in HA become scenes when synced to Google Home).