Custom template light via Broadlink universal remote (virtual light and virtual switch)

I just got BroadLink universal remote control BroadLink RM4 mini and thanks to integration called “SmartIR” with a preset code I was able to make my stupid AC → smart.

Now I got the BroadLink integration installed, and my remote is called “remote.office_remote” working. I purchased this LED light from AliExpress that has a remote control and here it what it looks like:
Aee906650d0a94ebbbad27574e0f48364E

Using the native app BroadLink I was able to teach the remote to control it, but I want to do this inside Home Assistant. I am newbie but made a bit of search and found out it might be possible with Custom template for custom light. Thank to ChatGPT I was able to make a light entity that I added to my dashboard.

- platform: template
  lights:
    my_broadlink_light:
      friendly_name: My Broadlink Light
      value_template: "{{ states('switch.my_broadlink_switch') }}"
      turn_on:
        service: switch.turn_on
        data:
          entity_id: switch.my_broadlink_switch
      turn_off:
        service: switch.turn_off
        data:
          entity_id: switch.my_broadlink_switch

However, for this to work I aparently need to make a custom switch as well, which I dont know how to write. I tried the following, but did not work

switch:
  - platform: broadlink
    host: 192.168.0.114
    mac: EC-0B-AE-FC-3B-45
    switches:
      my_broadlink_switch:
        friendly_name: My Broadlink Switch
        command_on: turn_on
        command_off: turn_off

I get this error: Invalid config for [switch.broadlink]: [my_broadlink_switch] is an invalid option for [switch.broadlink]. Check: switch.broadlink->switches->0->my_broadlink_switch. (See ?, line ?).

The remote has button for ON and button for OFF, which I made learn command “turn_off” and “turn_on”

I might be doing it wrong. How should be the switch configured and is it possible to make function of all the other buttons as well. Possibly color picker as RGB LED light or at least presets “red” “blue” “fade” “smooth” and etc.

I know this is kind of complex for a newbie as me, but i am sure there are many talented people here which it is possibly easy for you :slight_smile: Please help!

You do not make switches for the learned commands. The best way is to make scripts and on your dashboard you call the scripts with a button.

Here is an example of my LED candles, which have almost the same controller:

script of one of the buttons:

alias: Kaarsen groen
sequence:
  - service: remote.send_command
    target:
      entity_id: remote.broadlinkrm4woon_remote
    data:
      device: Kaarsen
      command: green
      num_repeats: 2
      hold_secs: 0.5
mode: single
icon: mdi:candle

And the corresponding button card on my dashboard:

type: button
tap_action:
  action: toggle
entity: script.kaarsen_groen
name: Kaarsen groen

with all the buttons created it looks like this:

afbeelding

Yes, I know the standard way is to make script with a buttons, but I want to go a different way. I want 1 light entity that uses Mushroom light card and to have on/off and possibly other functionality or at least on/off. Your way is OK, but I seek something different which i think is a bit more complex and I dont have the knowledge to do it. Thank you for your answer as well, I appreciate it.

Well, i did resolve that on/off even more different - with a smart switch, so the quiet power hungry cheap chinese transformer does not eat energy, when off :slight_smile:

switch:
  - platform: broadlink
    host: 192.168.0.114
    mac: EC-0B-AE-FC-3B-45
    switches:
      my_broadlink_switch:
        friendly_name: My Broadlink Switch
        command_on: poweron
        command_off: poweroff

  - platform: template
    switches:
      my_virtual_switch:
        friendly_name: My Virtual Switch
        value_template: "{{ is_state('switch.my_broadlink_switch', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.my_broadlink_switch
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.my_broadlink_switch

light:
  - platform: template
    lights:
      my_virtual_light:
        friendly_name: My Virtual Light
        value_template: "{{ states('switch.my_virtual_switch') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.my_virtual_switch
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.my_virtual_switch

I get this error: Invalid config for [switch.broadlink]: [my_broadlink_switch] is an invalid option for [switch.broadlink]. Check: switch.broadlink->switches->0->my_broadlink_switch. (See ?, line ?).

Here is an actual example

- platform: template
  switches:
    living_candles:
      friendly_name: "Bougies living"
      icon_template: "mdi:candelabra"
      turn_on:
        service: remote.send_command
        data:
          device: candles
          command: turn on
        target:
          entity_id: remote.broadlink_rm4c_remote
      turn_off:
        service: remote.send_command
        data:
          device: candles
          command: turn off
        target:
          entity_id: remote.broadlink_rm4c_remote

candles and, e.g., turn off are the device and command name I indicated when learning from the original remote.

1 Like