Broadlink IR Controller: Automating A/C in Multiple Rooms

I’ve recently set up a Broadlink IR controller in two different rooms to control my air conditioning units. Both A/C units are identical, so I was able to teach one Broadlink device the necessary IR commands and replicate this setup in the second room. This has been a fantastic way to streamline my home automation setup and make controlling the A/C units much more convenient.

Initially, I created a script to turn off the A/C unit in one room. The script uses the remote.send_command service to send the IR command, targeting the specific device using its entity ID. Here’s a snippet of the script I used:

yaml
alias: A/C Off
sequence:

  • service: remote.send_command
    data:
    device: A/C
    command:
    • Power Off
      target:
      device_id: ‘{{ data.entity_id }}’
      mode: single
      icon: mdi:fan-off

To extend this functionality to the second room, I wanted to reuse the same script but change the target entity dynamically. However, I ran into some issues when trying to pass the entity ID dynamically. After some research and experimentation, I realized that while the Broadlink devices can be controlled using the same script, dynamically changing the target entity requires careful handling of the entity IDs in the script calls.

Here’s how I set up the buttons in my Home Assistant dashboard to trigger the scripts for each room:

yaml
type: horizontal-stack
title: Master Bed Room A/C
cards:

  • type: vertical-stack
    cards:
    • show_name: true
      show_icon: true
      type: button
      tap_action:
      action: toggle
      entity: script.a_c_on_cold24auto
      name: :snowflake: A/C Cold 24’C Auto
      icon_height: 50px
  • type: vertical-stack
    cards:
    • show_name: true
      show_icon: true
      type: button
      tap_action:
      action: toggle
      entity: script.a_c_off
      data:
      entity_id: 4d0ef0dad66651b949659d663179aa64
      icon_height: 50px

While this setup works perfectly for controlling the A/C units in each room, I’m still exploring ways to make the script more versatile. If anyone has tips on how to handle dynamic entity IDs more effectively, I’d love to hear them! This project has been a great way to dive deeper into Home Assistant scripting and automation, and I’m excited to continue refining my setup.