Migrate Broadlink RM deprecated switch YAML?

Hey,

I looked through the topics mentioning “Broadlink” since the past few weeks and tried finding an answer in older topics, but no luck.

I knew this was coming, that there was going to be a breaking change and the old Base64 switch YAML configuration would be invalid for my RM Pro. I was also hoping there would be an easy way to migrate all the old switches, when that day comes.
That day came with the last monthly release and I can’t for the life of me find a way anywhere in the Broadlink integration docs. Am I missing something on how people like myself can migrate all the old IR and RF commands without relearning everything through the learn commands in Lovelace?

I have around 120+ (yeah, I know) RF and IR commands in my YAML since 2016. Most of which for remotes, which I no longer have, because they were cheapo little things for my wall switches.
A lot of which was painstakingly difficult to finally get the RM Pro to learn the right code (as I’m sure fellow Broadlink RF users can confirm).

As far as I understand, I can’t edit the files in the storage folder, to put in my codes.
So that leaves me with… Getting a new Broadlink RM, connecting it with another HA, sending those commands using the old way, so my original HA can learn the commands in Lovelace? :joy:

Any input is appreciated!

Thanks
Ben

Yes, you can.
HA devs discourages it because any mistakes there might render your HA inoperative, but if you know what you’re doing, do backups, …, nothing prevents you to do so.

You could also create a custom component with the 2021.12 version of the Broadlink integration, which still has YAML.

1 Like

So you are saying that your yaml configured switches didn’t get imported to the UI config? And your switches are no longer working?

according to the “breaking changes” section of the latest release it was supposed to be automatically done:

Broadlink

The previously deprecated YAML configuration of the Broadlink integration has been removed.

Broadlink is now configured via the UI, any existing YAML configuration has been imported in previous releases and can now be safely removed from your YAML configuration files.

I haven’t checked to see if mine have been imported or not yet. I just assumed they would be.

Since they don’t seem to create any entities in the integration it’s hard to know for sure what the source of those switches are right now. But I can’t find any entries in any of the .storage files for any broadlink switches.

I guess I may be in the same boat as you now. :slightly_frowning_face:

Have you submitted a bug report yet? Since the docs specifically say they should be imported then if they aren’t then I think it should be a bug that they aren’t.

(BTW, I’m still on the latest older version of HA so far…)

EDIT:

looking at the documentation it seems that the switches, etc should still be configured manually in yaml.

It looks like the only thing that is removed from yaml is the broadlink integration configuration itself.

So are your yaml configured switches no longer working?

Thank you!

Added the switches to the corresponding files in the storage folder; works just fine.

@finity I didn’t try everything that extensively when I tried an update and then reverted my snapshot. I just saw that all my Broadlink switches were no longer available in Lovelace, Notifications warned me that that part didn’t load and I checked the storage folder and saw none of the switches had been converted/imported. Maybe my YAML isn’t in a format it can be converted from?
And yes, I already had the Broadlink integration set up in the new way. Just without the switches.

In my Switch section of the YAML configuration, I have the broadlink platform and below it the switches with their codes. Like so Broadlink - Home Assistant

Not quite sure where it went wrong, but also just content with the solution of editing the codes into the folder which should not be touched :smiley:.

EDIT: According to the Broadlink integration page, I could have also created scripts, which use the remote.send_command to send the base64 codes.

would you mind posting the switch json format for adding your switches to the .storage folder?

which file did you add the json into to get them to work (entity_registry, device_registry, etc)?

it looks like I may be having to do this as well for the few RF switches I have in yaml now.

the documentation/breaking changes section is pretty misleading if nothing actually gets imported but also everything gets wiped out.

The easiest way is to use that remote.learn_command service for your Broadlink, teach it 2 devices with each 2 commands and then you’ll have it prepopulated.

{
    "version": 1,
    "minor_version": 1,
    "key": "broadlink_remote_YOURMACADDRESS_codes",
    "data": {
        "TESTdevice1": {
            "SetMe": "JgA4AAnECAACRwmJCgAB0Q0AAdILAAVyCwwGLg4IYhkFJCEADK9mBwcvIgwPFCwADNJ5CFAHDnAFAA0F"
        },
        "TESTdevice2": {
            "AndForgetMe": "JgBQAAABJ5QSExITEzcTExMSEhMTEhMSEzgSOBITEzgSOBI4EzgSOBQ3EhMSExM3EhQSExITEhMRFBM4EjgSExM4FDYSOBI5EgAFIAABJ0sSAA0FAAAAAAAAAAA=",
            "Forever": "JgBIAAABKJMUERITFDcUEREUFBEUERUQFTYUNhUQFTYUNhQ2FTYUNhU2FBEUERQ2EhQUERQRFBESExI5FDYUERQ3FDYUNhU2FAANBQ=="
        }
    }
}

EDIT: sorry, that was a mess at first.

Oh, and the file name is
“broadlink_remote_YOURMACADDRESS_codes”

Where YOURMACADDRESS would be replaced by lowercase… You guessed it: a cheeseburger.

Just so I’m not the wreaker of havoc: we should probably let the file get created by the HA Lovelace and all, instead of just creating the files, setting some random permissions and then complaining in the forums why nothing is working anymore.

1 Like

This integration is brilliant. I suggest checking it out.

1 Like

@Benjamin_De_Smet

Does the above file create switch entities in HA or remote entities?

The docs there are a little sparse on what is necessary to create entities from existing device codes.

And it doesn’t look like it supports switch entities?

All of my broadlink entities are configured as switches and I have an existing code for each.

TBH, I’m still trying to figure out if this is even going to be an issue. the docs seem to indicate that what I have now should still work.

So SmartIR basically gives you a way to combine multiple ‘switch’ entities into a ‘controller’ I guess you could say, which becomes a Media Player, Climate or Fan entity.

eg:
Instead of having a ‘switch’ entity for each button of a physical remote control for a HiFi system that you learn the codes from, you then create a Media Player entity and all the ‘switch’ codes become associated with the Media Player. I have learnt a bunch of codes from my old (non-smart) Onkyo surround sound receiver and added them to a file which SmartIR uses to create a Media Player. In HA that Media Player entity is now the equivalent of a smart Onkyo receiver. I can use volume up/down, select input source etc. and SmartIR will send the required codes to the Broadlink IR blaster. Using a smart power plug with power monitoring I get feedback to HA (and into SmartIR) as to whether or not the amp is on or off.

1 Like

Personally, I think it is crazy even I’ve already seen the warning message about the broadlink component shows will not support the Yaml configuration a long time ago, and I found after I installed the updates of HA yesterday it broke all my broadlink switches and no solution about the switches.
I use Google Speak (Nest, Home, TV) to control all these devices with on and off and now it made me confused about how could I solve this problem.
And again, personally, I won’t remove the configuration in Yaml which just like the Modbus component there are a lot of things customized.
The only solution is trying to copy and paste the old broadlink component to the customized folder I think, and I will try it later.

Unfortunately neither :neutral_face:. As far as I can tell, this doesn’t create any entities. It’s just a library of remote commands in the background you can run using remote.send_command service calls. But you need to check that ‘library’ for the exact name, if you can’t remember, in order to run a specific command.

@sparkydave I agree with @finity, that the docs are sparse.
Is it limited to fans, media players and climate, or are those just most commonly used?

So I think my solution will be to make template switches (since I have quite a lot of lights and sockets running 433mhz stateless RF, and a lot of IR stuff) in order to get a state after calling a remote command.

For example:

I often combined RF and IR for a device, like the socket for my speakers and then the actual power button for them. Stuff I can’t really pack into a media player, because a universal media player doesn’t support several ‘power stages’.
Neither does it support individual channel volumes like rear, center, bass. But that’s just a general HA wish of mine :sweat_smile:.

This whole breaking change really adds a layer of complexity to my config, which I wasn’t hoping for. If anyone has a better solution, feel free to stop me :grin:.

EDIT:
@finity 2022.2: Let's start streamlining! - #881 by finity

Took a snapshot and updating right now, just to confirm what I saw.

Results in my next post.

It is at the moment but the dev has been really good in the past, perhaps a feature request to expand the component would be taken up.

1 Like

So my errors included

Screenshot_20220211-062816_Home Assistant

Kitchen lights is the first switch in my Broadlink YAML list.
So I looked at the docs for Broadlink and saw the syntax is slightly different from what I had.
Added that sample Philips TV switch, just to show the difference.

As soon as this was changed to reflect the sample syntax, it accepted my config for kitchen lights.
Which means I just had an old config syntax, which is now no longer valid. As soon as you edit the config to reflect the docs, then the YAML config works again. Hurrah.

So just to quote myself from post 4: “Maybe my YAML isn’t in a format it can be converted from?”
Seems I was close :sweat_smile:.

1 Like

Some very good suggestions were already made, but wanted to add another angle: I’ve had a Broadlink RM for quite a while and learned all the codes initially and haven’t touched it since (also, the learn function at that point in time in the integration was broken so I had to learn/capture codes outside of HA). I made a script for every button press which works by sending the hex codes in scripts. This avoids having it all stored in the JSON files, so if you’re someone that for some reason wants it more easily and safely editable, this is another way. Not as nice as the HACS integration that creates devices.

I didn’t get it why you still trying to use the configuration that the component has already removed the YAML configuration and the document page is outdated.

To be honest, this update of the broadlink component is like a real SHIT which it makes no sense to remove the supports of the YAML configurations.

1 Like

@Benjamin_De_Smet please not mark your response as the solution as you are misleading all other ppl with mass confusion. You haven’t solved your problem yet and just mark your post as the solution?

I have solved my problem, because if I change the syntax like I did in my last post (as the docs state I should), then my YAML config works for Broadlink.
Sure, I didn’t figure out the automatic import of switches into UI yet, but that’s something else…

If you want, I can update here as soon as I get around to fixing my YAML Syntax so the switches get imported (if I understand correctly) and then update to the current release.
(I reverted my snapshot, because I didn’t have time now to fix all of it)

Yup. Pain in the …