[FR] Broadlink Integration - Shared Remote Codes across multiple Broadlink Remotes

At present, the Broadlink integration creates an individual remote code file for each Broadlink Remote that is added to Home Assistant. As a result, remote codes learned by, for example Device A, can only be called using the Command Name by Device A. Other Broadlink Remotes (Devices B & C) can only use the Base 64 code if called via a YAML service call.

Instead, codes learned by any Broadlink remote should be stored in such a way that any other Broadlink Remote can leverage the stored Command Name, assuming said device supports the given transmission method (IR or RF).

Just raising an issue here, this will/could cause breaking changes.

If living room has a TV and broadlink then you learn on/off button.
If the kitchen has a different TV and broadlink you learn it on/off.

So which on/off is now correct?
Also some might have this templated to know what room you are in and just fire off on/off button to the broadlink in that room.

Personally I did have a couple of identical TV’s and did only learn the codes once. I edited the backend JSON to duplicate them over in .storage. It was easier than learning them twice.

So voted…

I tried editing the codes files but HA ended up reverting my changes. Still, I’d rather not have to edit anything in .storage and I’m certain the devs would agree.

Only an issue if generic or identical device names are used. Regardless, the devs are quite clever. They’re also not afraid of breaking changes. :slight_smile:

Yeah… sadly…

An alternative would be to use scripts. From back in the day, I manually captured all the codes I needed. You can parameterise the entity ID to use the correct remote:

script:
  hk_3380_power_off:
    sequence:
      - service: remote.send_command
        data:
          entity_id: remote.living_room_remote
          command:
            - b64:JgBQAAABIZQTEhMSExITEhMSExITExI3ExITExMSExITNxM2EzcTEhM3EzcTNxM3EzYTExITEzcTExITEhMTExMSEzcTNxITEgAFpgABJ0kTAA0FAAAAAAAAAAA=

You still need scripts, but I store the commands in .storage.

  vizio_j_ch_down:
    sequence:
      - service: remote.send_command
        data:
          entity_id: remote.downstairs_mini_remote
          device: vizio
          command: ch_down
    "version": 1,
    "key": "broadlink_remote_blahblahID_codes",
    "data": {
        "vizio": {
            "av": "JgBgAAABKJIUERQRFDYUERQRFBIUERQRFDYUNRQSFDUUNhQ2FDYUNhQ1FBIUERQRFDYUERQ2FBEUERQ2FDUUNhQRFDYUERQ2FAAFGgABKUgUAAxTAAEoSBUADFIAAShJFAANBQAAAAAAAAAA",
            "ch_down": "JgBgAAABJ5MUERQRFDYUERQRFBEUEhMSEzYUNhQRFDYUNhQ2FDYTNhQ2FBEUEhMSFBEUERQRFBEUERQ2FDYUNhQ2EzYUNhQ2FAAFHAABKEgUAAxUAAEpSBQADFQAAShJFAANBQAAAAAAAAAA",
            "ch_up": "JgBYAAABKJIUERQSEzYTExMSFBEUERQRFDYUNhMSFDYTNhQ2FDYUNhQRFBETEhMSFBITEhMSFBEUNhQ2EzYUNhQ2EzcUNhM2FAAFHAABKEkUAAxUAAEoSRMADQU=",
            "hdmi": "JgBgAAABKZEUEhMSFDYSExMSFBETEhQREzcUNhQRFDYTNxM2EzcTNxMSEzcUNhQRFBETEhQ2FDYUNhQRExITNxQ1EzcUEhMSEwAFGwABKEkUAAxSAAEoSRQADFMAAShIFAANBQAAAAAAAAAA",
            "input": "JgBgAAABKJIUERQRFDYUERQRFBITEhQRFDYUNRQSEzYUNhQ2FDYUNhQ1FDYUNhQ2FBEUNhQRFBEUERQRFBITEhQ1FBITNhQ2FAAFHAABKEkUAAxUAAEoSBQADFUAAShIFAANBQAAAAAAAAAA",
            "mute": "JgBgAAABKJIUEhMSEzcTEhMSExIUERQRFDYUNhQRFDYTNxM2FDYUNhQ2FBEUERQ2FBEUERQRFBEUEhM2FDYUERQ2FDYUNhQ2EwAFHAABKEkUAAxUAAEoSRMADFUAAShJEwANBQAAAAAAAAAA",
            "power": "JgB4AAABKJIUERQRFDYUERQRFBEVERQRFDUVNRQSFDUUNhQ2FDYUNhQRFBEUERQ2FBEUERQRFBEUNhQ2FDYUERQ2FDUVNRQ2FAAFGgABKUgUAAxTAAEoSRQADFIAASlIFAAMUwABKEgVAAxSAAEpSBQADFMAAShIFAANBQ==",
            "tv": "JgBgAAABJ5USEhEUEzcRExETERQQFBETETkSOBETETkROBI4ETkROBQRETgRORITEDkSEhE3FjYROBEUERMRORMRETkRExEUEAAFLwABKUgRAAxaAAEmSxIADFkAASZLEQANBQAAAAAAAAAA",
            "vol_down": "JgBgAAABKJIUERQSEzYUERQSFBEUERQRFDYUNhMSFDUVNRQ2FDYUNhQ2FDUUEhQRFBEUERQRFBEUERQRFDYUNhQ2FDYUNRQ2FAAFGwABKEgUAAxTAAEoSRQADFMAAShIFAANBQAAAAAAAAAA",
            "vol_up": "JgBgAAABKJIUEhQRFDYTEhQRExIUERQRFDYUNhQRFDYUNhQ1FDYUNhQRFDYUERQRFBEUEhMSExIUNhMSFDYTNxM2FDYUNhM3FAAFGgABKEkUAAxSAAEpSBQADFMAAShJEwANBQAAAAAAAAAA"
        },

I used the learn process to build one of them, then the learn process to build one button of the second one, then edited in the remaining codes. That way HA built everything structure in the JSON, I just had to add rows.

But not having to screw with .storage is the best way for sure.

2 Likes

FYI the way to achieve this is to shut down HA, make your edits and then start HA again. But I agree, fiddling with .storage is not the way.

1 Like