Hass.io Broadlink RM Switch send multiple commands

Hi all,

Totally new here, absolutely love Home Assistant after having only played around with it for a few hours.

I have successfully setup Home Assistant along with google assistant and have added the Broadlink RM Switch to my config.yaml file and am able to get this to turn on and off a projector (IR) and screen (RF) which is awesome.

My question is, is it possible to setup a switch/ command to send both commands at the same time, so that I can say to google assistant ‘bedroom projector on’ / ‘bedroom projector off’ and it would fire both commands, rather than having to say ‘projector on’… ‘screen on’, etc.

My projector doesn’t have a seperate on/off button and requires the power button to be pressed twice to turn it off, is there a way in the off command I can get it to send this command twice?

Here is my config for the RM:

switch:

  • platform: broadlink
    host: 192.168.1.205
    mac: ‘REMOVED’
    timeout: 15
    switches:
    screen:
    friendly_name: “Screen”
    command_on: ‘sgAMAQ8tLw8QLQ8tLw8vEC8PEC0PLi4QDy4PLQ8AAc4uEA8tLw8vDzAPEC0vEA8uLw8QLi8QLxAPLi8QDy4PLi8QMBAvEBAtEC4vEBAtEC0QAAHPLw8QLS8QLxAwEA8uMA8QLi8QEC4vEDAQEC4wEA8uEC4vEDEPMRAPLw8uMBAQLg8uEAAB0S8QDy4vEDAQMBAPLy8RDy4wEBAuMBAwEQ8vMBAQLg8vMBAwETAQEC8PLjEQEC4QLg8AAdMwDxAuLxAwEDEQEC4wEBAuMRAPLzAQMRAQLzARDy8PLzAQMRAyEBAuEC8wEBAvDy8QAAHULxAQLjAQMBEwEBAvMBAQLjEQEC8wETEQEC8xEAYABdwAAAAAAAAAAAAAAAA=’
    command_off: ‘sgDuAA4uLhAPLS8PLxAPLi4QDy4PLS8QLhAvEBAtEC0PLi8PEC4OAAHPLhAPLi4QLxAvEA8uLxAPLy4QEC4vEC8QEC4vEA8vDy4vEDAQMBAPLw8uDy4vEBAuDwAB0S8QDy4uEDAQMBAPLjAQDy8vEBAuMBAwEA8vMBAQLg8uMBAxEDARDy8PLhAuMBAPLw8AAdMvEA8uMBAwEDAQDy8wEA8vMBAQLy8RMBEPLzAQEC4QLjARMBEwEQ8vEC4QLjARDy8QAAHTMBAPLjAQMBEwEBAvMBAQLjEQEC8wEDERDy8wERAvDy8wEDERMREPMAQABdwAAAAAAAAAAAAA’
    projector:
    friendly_name: “Projector”
    command_on: ‘JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==’
    command_off: ‘JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==’

Thanks in advance, I’ve been waiting so long to ditch these remotes… almost there!

1 Like

Create a script with the multiple commands. If you name it correctly it should be enough just for that.

However I am not sure how google home reacts with names and home assistant scripts (I use Alexa)

If that isn’t quite enough then set up a template switch with your scripts as on and off.

Agree with EGO01.

I have a script that operates several button pushes on my remote. You might need to put some delays in between the send commands or the device might see it as a single button push (single code)

Hi, thanks for the reply!

Would you be able to share your script, so I have a starting point? Does the script live in the config.yaml or in the dev area?

Thanks

I have my config split so this is in my scripts.yaml

stereo_vol_up:
  alias: Stereo up
  sequence: 
    - service: switch.broadlink_send_packet_192_168_1_4
      data:
        packet:
          - "JgBOAB4dHR0eHDwcHhweHB4cHjg8HR0dHR0eAArIHR0dHR4cPBweHB4cHhweOTsdHR0dHR4ACsgdHR0dHhw8HB4cHhweGx85Ox0dHR4cHgANBQAAAAAAAAAAAAA="
          - "JgBOAB4dHR0eHDwcHhweHB4cHjg8HR0dHR0eAArIHR0dHR4cPBweHB4cHhweOTsdHR0dHR4ACsgdHR0dHhw8HB4cHhweGx85Ox0dHR4cHgANBQAAAAAAAAAAAAA="

oh wow this looks pretty straightforward, I’ll give this a try and report back. I’m going to add a couple of waits in there.

I’ve setup the following code in scripts.yaml
equipment_on:
alias: Equipment On
sequence:
- service: switch.broadlink_send_packet_192_168_1_205
data:
packet:
- “sgAMAQ8tLw8QLQ8tLw8vEC8PEC0PLi4QDy4PLQ8AAc4uEA8tLw8vDzAPEC0vEA8uLw8QLi8QLxAPLi8QDy4PLi8QMBAvEBAtEC4vEBAtEC0QAAHPLw8QLS8QLxAwEA8uMA8QLi8QEC4vEDAQEC4wEA8uEC4vEDEPMRAPLw8uMBAQLg8uEAAB0S8QDy4vEDAQMBAPLy8RDy4wEBAuMBAwEQ8vMBAQLg8vMBAwETAQEC8PLjEQEC4QLg8AAdMwDxAuLxAwEDEQEC4wEBAuMRAPLzAQMRAQLzARDy8PLzAQMRAyEBAuEC8wEBAvDy8QAAHULxAQLjAQMBEwEBAvMBAQLjEQEC8wETEQEC8xEAYABdwAAAAAAAAAAAAAAAA=”
- “JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==”
equipment_off:
alias: Equipment Off
sequence:
- service: switch.broadlink_send_packet_192_168_1_205
data:
packet:
- “sgDuAA4uLhAPLS8PLxAPLi4QDy4PLS8QLhAvEBAtEC0PLi8PEC4OAAHPLhAPLi4QLxAvEA8uLxAPLy4QEC4vEC8QEC4vEA8vDy4vEDAQMBAPLw8uDy4vEBAuDwAB0S8QDy4uEDAQMBAPLjAQDy8vEBAuMBAwEA8vMBAQLg8uMBAxEDARDy8PLhAuMBAPLw8AAdMvEA8uMBAwEDAQDy8wEA8vMBAQLy8RMBEPLzAQEC4QLjARMBEwEQ8vEC4QLjARDy8QAAHTMBAPLjAQMBEwEBAvMBAQLjEQEC8wEDERDy8wERAvDy8wEDERMREPMAQABdwAAAAAAAAAAAAA”
- “JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==”
- “JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==”

I can run the scripts from the frontend of HASS and they work - how can I get these to work with google assistant/ Alexa? It sees the scripts, but fails to execute them.

I am not sure about google but Alexa see’s the scripts as scenes. This means you have to say Alexa turn on equipment on (based on your example). Which isn’t very intuitive.

In alexa I can get around this with routines but a better way is to create a template switch then use the filter to block the scripts coming through (if you need to) . Alexa see’s the template as the actual switch

Heres my example for the stereo under switches in config.yaml:

  - platform: template
    switches:
      stereo:
        value_template: "{{ is_state( 'switch.hifi_switch_broadlink', 'on') }}"
        turn_on:
          service: script.turn_on
          data:
            entity_id: script.stereo_on 
        turn_off:
          service: script.turn_on
          data:
            entity_id: script.stereo_off

For Google, you’ll need to add hassio as skill in the google home app and log into the Home assistant cloud within the Home assistant configuration settings within the front end.

Once you do this, it will expose all of your home Assistant devices and entities to google. You can call scripts by saying “ok google, activate YOUR_SCRIPT_NAME”

HI,

I have google assistant setup and working. It was able to turn on and off all switches (individually). However, when i unlink my account and drink it to Google home, it’s not pulling through the latest script names. All config is fine and I can call the scripts from the front end, when i ask google, it can’t find the scripts.

Other than unblinking and relinking the hassle account I’m not sure what else I can do

Have you got filters set up to block scripts? For Alexa cloud you can filter by the domain so if scripts are blocked that way none would come through.

Try the template switch and see if that comes through

Ok, so I have managed to get the projector and screen to turn on, using google assistant. But I can’t get them to turn off. If I execute the scripts from the hassio portal, they work, so I think it is a misconfiguration with my switch template?

    switches:
  projector:
    friendly_name: "Screen"
    value_template: "{{ is_state( 'switch.screen', 'on') }}"
    turn_on:
      service: script.turn_on
      data:
        entity_id: script.equipment_on 
    turn_off:
      service: script.turn_on
      data:
        entity_id: script.equipment_off

I think that the value_template maybe incorrect? What should this be referencing?

I think some of you’re spacing is off and the platform is missing. I’m surprised this hasn’t given you some errors in the config checker or on restart??

Anyway I think it should be something like this:

switch:
  - platform: template
    switches:
    projector:
        value_template: "{{ is_state('switch.screen', 'on') }}"
        turn_on:
          service: script.turn_on
          data:
            entity_id: script.equipment_on
        turn_off:
          service: script.turn_off
          data:
            entity_id: script.equipment_off

Also the value template needs to refer to an existing device. As long as the switch.screen is in your entities and works thats fine.

Hi, I can get google assistant to turn on and off “Projector” and “Projector Screen”. I’ve gone through my config again, I can get google assistant to turn on “Screen” but not turn it off - it doesn’t even attempt to fire the commends to the Broadlink RM Pro. I think it’s a problem with the value_template still, it’s referencing a switch in my config.yaml (below) - is this correct? Here is a full dump of the config.yaml and scripts.yaml:

Config.yaml:
switch:

  • platform: broadlink
    host: 192.168.1.205
    mac: ‘REMOVED’
    timeout: 15
    switches:
    projector_screen:
    friendly_name: “Projector Screen”
    command_on: ‘sgAMAQ8tLw8QLQ8tLw8vEC8PEC0PLi4QDy4PLQ8AAc4uEA8tLw8vDzAPEC0vEA8uLw8QLi8QLxAPLi8QDy4PLi8QMBAvEBAtEC4vEBAtEC0QAAHPLw8QLS8QLxAwEA8uMA8QLi8QEC4vEDAQEC4wEA8uEC4vEDEPMRAPLw8uMBAQLg8uEAAB0S8QDy4vEDAQMBAPLy8RDy4wEBAuMBAwEQ8vMBAQLg8vMBAwETAQEC8PLjEQEC4QLg8AAdMwDxAuLxAwEDEQEC4wEBAuMRAPLzAQMRAQLzARDy8PLzAQMRAyEBAuEC8wEBAvDy8QAAHULxAQLjAQMBEwEBAvMBAQLjEQEC8wETEQEC8xEAYABdwAAAAAAAAAAAAAAAA=’
    command_off: ‘sgDuAA4uLhAPLS8PLxAPLi4QDy4PLS8QLhAvEBAtEC0PLi8PEC4OAAHPLhAPLi4QLxAvEA8uLxAPLy4QEC4vEC8QEC4vEA8vDy4vEDAQMBAPLw8uDy4vEBAuDwAB0S8QDy4uEDAQMBAPLjAQDy8vEBAuMBAwEA8vMBAQLg8uMBAxEDARDy8PLhAuMBAPLw8AAdMvEA8uMBAwEDAQDy8wEA8vMBAQLy8RMBEPLzAQEC4QLjARMBEwEQ8vEC4QLjARDy8QAAHTMBAPLjAQMBEwEBAvMBAQLjEQEC8wEDERDy8wERAvDy8wEDERMREPMAQABdwAAAAAAAAAAAAA’
    projector:
    friendly_name: “Projector”
    command_on: ‘JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==’
    command_off: ‘JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==’
  • platform: template
    switches:
    screen:
    friendly_name: “Screen”
    value_template: “{{ is_state( ‘switch.projector_screen’, ‘on’) }}”
    turn_on:
    service: script.turn_on
    data:
    entity_id: script.equipment_on
    turn_off:
    service: script.turn_off
    data:
    entity_id: script.equipment_off

Scripts.yaml:
equipment_on:
alias: Equipment On
sequence:
- service: switch.broadlink_send_packet_192_168_1_205
data:
packet:
- “sgAMAQ8tLw8QLQ8tLw8vEC8PEC0PLi4QDy4PLQ8AAc4uEA8tLw8vDzAPEC0vEA8uLw8QLi8QLxAPLi8QDy4PLi8QMBAvEBAtEC4vEBAtEC0QAAHPLw8QLS8QLxAwEA8uMA8QLi8QEC4vEDAQEC4wEA8uEC4vEDEPMRAPLw8uMBAQLg8uEAAB0S8QDy4vEDAQMBAPLy8RDy4wEBAuMBAwEQ8vMBAQLg8vMBAwETAQEC8PLjEQEC4QLg8AAdMwDxAuLxAwEDEQEC4wEBAuMRAPLzAQMRAQLzARDy8PLzAQMRAyEBAuEC8wEBAvDy8QAAHULxAQLjAQMBEwEBAvMBAQLjEQEC8wETEQEC8xEAYABdwAAAAAAAAAAAAAAAA=”
- “JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==”
equipment_off:
alias: Equipment Off
sequence:
- service: switch.broadlink_send_packet_192_168_1_205
data:
packet:
- “sgDuAA4uLhAPLS8PLxAPLi4QDy4PLS8QLhAvEBAtEC0PLi8PEC4OAAHPLhAPLi4QLxAvEA8uLxAPLy4QEC4vEC8QEC4vEA8vDy4vEDAQMBAPLw8uDy4vEBAuDwAB0S8QDy4uEDAQMBAPLjAQDy8vEBAuMBAwEA8vMBAQLg8uMBAxEDARDy8PLhAuMBAPLw8AAdMvEA8uMBAwEDAQDy8wEA8vMBAQLy8RMBEPLzAQEC4QLjARMBEwEQ8vEC4QLjARDy8QAAHTMBAPLjAQMBEwEBAvMBAQLjEQEC8wEDERDy8wERAvDy8wEDERMREPMAQABdwAAAAAAAAAAAAA”
- “JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==”
- “JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ==”

spacing is all fine and passes config checks, I just can’t get it to paste into the browser as code when when I press the preformatted text button - so spacing will look off.

I used to use a script but that never worked well.

What finally worked was using https://dimagoltsman.github.io/Random-Broadlink-RM-Code-Generator/ to generate a twice repeated power toggle code from my existing single press code. Go to the “Change Repeats” tab and enter your existing code and 1 in the repeat box.

Works 100% of the time now.

Oh and for the screen, I use an automation that lowers the screen along with the projector turning on.

3 Likes

It’s very hard to tell without the spacing. The only way I can think to test is to add the template switch to the front end and manually turn it on and off that will test if the problem is in the template. Also check all scripts and entities work individually too

Ok, so I still have the same problem - I can turn the “screen” on but not turn it off using google assistant. Calling the scripts (on/off) in Hassio work.

Can someone advise if value_template: “{{ is_state( ‘switch.projector_screen’, ‘on’) }}” is correct, as Hassio never changes the state, so I am guessing when I am calling the template switch “Screen” it’s not seeing the projector_screen actually being on, so it doesn’t run the turn off command?

Here is all of my config, hopefully this posts ok.

Configuration.yaml

switch:
  - platform: broadlink
    host: 192.168.1.205
    mac: 'REMOVED'
    timeout: 15
    switches:
      projector_screen:
        friendly_name: "Projector Screen"
        command_on: 'sgAMAQ8tLw8QLQ8tLw8vEC8PEC0PLi4QDy4PLQ8AAc4uEA8tLw8vDzAPEC0vEA8uLw8QLi8QLxAPLi8QDy4PLi8QMBAvEBAtEC4vEBAtEC0QAAHPLw8QLS8QLxAwEA8uMA8QLi8QEC4vEDAQEC4wEA8uEC4vEDEPMRAPLw8uMBAQLg8uEAAB0S8QDy4vEDAQMBAPLy8RDy4wEBAuMBAwEQ8vMBAQLg8vMBAwETAQEC8PLjEQEC4QLg8AAdMwDxAuLxAwEDEQEC4wEBAuMRAPLzAQMRAQLzARDy8PLzAQMRAyEBAuEC8wEBAvDy8QAAHULxAQLjAQMBEwEBAvMBAQLjEQEC8wETEQEC8xEAYABdwAAAAAAAAAAAAAAAA='
        command_off: 'sgDuAA4uLhAPLS8PLxAPLi4QDy4PLS8QLhAvEBAtEC0PLi8PEC4OAAHPLhAPLi4QLxAvEA8uLxAPLy4QEC4vEC8QEC4vEA8vDy4vEDAQMBAPLw8uDy4vEBAuDwAB0S8QDy4uEDAQMBAPLjAQDy8vEBAuMBAwEA8vMBAQLg8uMBAxEDARDy8PLhAuMBAPLw8AAdMvEA8uMBAwEDAQDy8wEA8vMBAQLy8RMBEPLzAQEC4QLjARMBEwEQ8vEC4QLjARDy8QAAHTMBAPLjAQMBEwEBAvMBAQLjEQEC8wEDERDy8wERAvDy8wEDERMREPMAQABdwAAAAAAAAAAAAA'
      projector:
        friendly_name: "Projector"
        command_on: 'JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ=='
        command_off: 'JgJoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ=='
  - platform: template
    switches:
      screen:
        friendly_name: "Screen"
        value_template: "{{ is_state( 'switch.projector_screen', 'on') }}"
        turn_on:
          service: script.turn_on
          data:
            entity_id: script.equipment_on 
        turn_off:
          service: script.turn_off
          data:
            entity_id: script.equipment_off

Scripts.yaml

equipment_on:
  alias: Equipment On
  sequence: 
    - service: switch.broadlink_send_packet_192_168_1_205
      data:
        packet:
          - "sgAMAQ8tLw8QLQ8tLw8vEC8PEC0PLi4QDy4PLQ8AAc4uEA8tLw8vDzAPEC0vEA8uLw8QLi8QLxAPLi8QDy4PLi8QMBAvEBAtEC4vEBAtEC0QAAHPLw8QLS8QLxAwEA8uMA8QLi8QEC4vEDAQEC4wEA8uEC4vEDEPMRAPLw8uMBAQLg8uEAAB0S8QDy4vEDAQMBAPLy8RDy4wEBAuMBAwEQ8vMBAQLg8vMBAwETAQEC8PLjEQEC4QLg8AAdMwDxAuLxAwEDEQEC4wEBAuMRAPLzAQMRAQLzARDy8PLzAQMRAyEBAuEC8wEBAvDy8QAAHULxAQLjAQMBEwEBAvMBAQLjEQEC8wETEQEC8xEAYABdwAAAAAAAAAAAAAAAA="
          - "JgBoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ=="
equipment_off:
  alias: Equipment Off
  sequence: 
    - service: switch.broadlink_send_packet_192_168_1_205
      data:
        packet:
          - "sgDuAA4uLhAPLS8PLxAPLi4QDy4PLS8QLhAvEBAtEC0PLi8PEC4OAAHPLhAPLi4QLxAvEA8uLxAPLy4QEC4vEC8QEC4vEA8vDy4vEDAQMBAPLw8uDy4vEBAuDwAB0S8QDy4uEDAQMBAPLjAQDy8vEBAuMBAwEA8vMBAQLg8uMBAxEDARDy8PLhAuMBAPLw8AAdMvEA8uMBAwEDAQDy8wEA8vMBAQLy8RMBEPLzAQEC4QLjARMBEwEQ8vEC4QLjARDy8QAAHTMBAPLjAQMBEwEBAvMBAQLjEQEC8wEDERDy8wERAvDy8wEDERMREPMAQABdwAAAAAAAAAAAAA"
          - "JgJoAQABJZQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBITEgAFPQABJpQSOBE4EhQRFBEUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBITEjgSOBEUEQAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExIUETgSOBI4ETgSOBITEjgSOBITEgAFPQABJpQSOBI4EhMSExITEhMSExI4EjgSExI4EhMSOBITEjgRFRETEhMSExITEjgSExITEjgROBI4EjgSOBITEjgSOBITEgAFPQABJpQSNxI4EhMSExIUERQRFBE4EjgSExI4EhMSOBITEjgSExITEhMSExITEjgSExITEjgSOBI4EjgSOBEUEjcSOBITEgANBQ=="

Would you be able to share your automation for the lowering of the screen and projector turning on? I will see if I can get this working with my codes.

I don’t think so. It needs to be an entity that when the template is switched on, will also be switched on, so the template can evaluate its state against it. Because in your script you have the send packet command it doesn’t turn the switch.projector_screen on in home assistant. (Hope that makes sense)

I think you could change the scripts so that the sequence is:

-  service: switch.turn_on:
   entity_id: switch.projector_screen (or however the entity of the switch appears in your HA instance)
-  service: switch.turn_on
   entity_id: switch.projector  (or however the entity of the switch appears in your HA instance)

This should have the same affect as sending the command twice but the first will tell home assistant and the template that the switch is on.

You will need to do the same for the off script but with switch_turn off of course :grin:.

Check the revised scripts work as you might need to put a delay in there. I find my broadlink works better if I put a very small delay of either 0.25 to 0.5 seconds

Thanks for posting in correct format it is much easier to see the problem

1 Like