Core: Failed to connect to device (Broadlink RM Mini3)

Created on 30 Apr 2019  路  91Comments  路  Source: home-assistant/core

Home Assistant release with the issue:
0.92.1

Last working Home Assistant release (if known):
N/A

Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io

Component/platform:
/components/broadlink/

Description of problem:
I am unable to connect to my Broadlink RM Mini3. The component itself loads correctly, but I get the following error when I call the broadlink.learn service.

2019-04-30 21:12:42 ERROR (MainThread) [homeassistant.components.broadlink] Failed to connect to device

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

switch:
  - platform: broadlink
    host: 192.168.1.19
    mac: 'C8:F7:42:62:8A:37'
    timeout: 30    

I've double and triple checked the IP address and MAC address and it seems fine.

Additional information:
The RM Mini 3 works fine when I use the IHC app on my phone. I can ping the IP address fine on my computer.

When I try to use Broadlink Manager, I get the following error too.

Found device : Unknown [192.168.1.19]
Writing compatible device not detected!

I'm not sure if it's related.

It's possible that the version of RM Mini 3 I have maybe slightly different to most, because I bought mine from Taobao, so the labelling on the bottom of it is in Chinese, while most of the ones I see on YouTube have English labelling. However, I'm not sure whether there is a way to fix it.

broadlinkRM3

Most helpful comment

When will this issue be fixed?

All 91 comments

I'm also running 0.92.1 and I get the same error every so often, usually after i restart the wifi.
I have 2, and like you i can ping them, connect with their app (and using a python script), but can't control with Home Assistant.
To get them back up and running with the broadlink component i power cycle them and restart Home Assistant.
Up to now, that's always resolved it for me.

I'm experiencing the exact same issue. Even after a reboot of both the RM mini and HASSIO it doesn't work.

I'm experiencing the exact same issue. Even after a reboot of both the RM mini and HASSIO it doesn't work.

Are you using the Chinese Broadlink or the International version?

The Chinese version. Do I need to do anything differently?

The Chinese version. Do I need to do anything differently?

I'm wondering if the international version makes a difference.

+1
my RM Mini 3 arrived 2 days ago
working with Broadlink manager and can learn IR codes.
in HA I get told failed to connect to device.
Something I noticed is that the service says "broadlink.learn"
all of the tuts I have seen online shows the services have the IP in the name.

same issue with HA @ 0.93.1
the service is now broadlink.learn
and requires JSON like
{
"host": "ip"
}
but i'm getting the same error: /components/broadlink/__init__.py: Failed to connect to device

I'm also having the same issue with 0.93.1 and my Broadlink RM-Mini3 where sending the command broadlink.learn logs out "Failed to connect to device".

However I've put a switch into the configuration YAML and can see the light on the Broadlink flashing when I toggle the switch which shows that it is able to communicate with the RM-Mini3. This would suggest that it's an issue with the broadlink.learn command

Is there any workaround we can use for this? Maybe learn through another piece of software?

Robhofmann you can learn command with broadlink manager (windows exe)
But without the ability to connect to the device I can't send any commands.

I'm also having the same issue with 0.93.1 and my Broadlink RM-Mini3 where sending the command broadlink.learn logs out "Failed to connect to device".

However I've put a switch into the configuration YAML and can see the light on the Broadlink flashing when I toggle the switch which shows that it is able to communicate with the RM-Mini3. This would suggest that it's an issue with the broadlink.learn command

@wzwick this comment is saying that the send commands do work. I havent got the change to try this yet. I'll try this asap.

For me I can neither learn nor send.
Please let me know anything you find out.

I'm also having the same issue with 0.93.1 and my Broadlink RM-Mini3 where sending the command broadlink.learn logs out "Failed to connect to device".
However I've put a switch into the configuration YAML and can see the light on the Broadlink flashing when I toggle the switch which shows that it is able to communicate with the RM-Mini3. This would suggest that it's an issue with the broadlink.learn command

@wzwick this comment is saying that the send commands do work. I havent got the change to try this yet. I'll try this asap.

I read that comment as it saying that while they cant send commands by adding a 'hacky' switch they can prove there is communication to the device.

I added a switch (as described in the documentation https://www.home-assistant.io/components/broadlink/) with a bogus "command_on" and "command_off" base64 string which caused the LED to flash on the Broadlink when toggled. This suggested to me that there was communication between the Broadlink and homeassistant.

I just tested it. Using the broadlink manager to learn the commands, I got it to work.

The sending of the commands works like a charm.

Here is my config:

- platform: broadlink
  host: 192.168.0.123
  mac: 'a8:f7:f2:6e:fe:81'
  type: 'rm_mini'
  friendly_name: 'Broadlink RM 3 Mini Bedroom'
  switches:
    tv_lift_bedroom:
      friendly_name: TV Lift
      command_on: 'JgAsAQADiJ6anpkABOwAA4yemp6ZAAdhAAOMnpmemgAE6wADjZ6Zn5kAB2AAA4yemZ+ZAATrAAOOnZqemQAHXwADjp2anpkABOsAA4+dmZ6aAAdfAAOOnZqemQAE6wADjZ6anpkAB18AA4+dmaGXAATrAAONnpmemgAHXwADjZ6anpoABOoAA4+cmp6ZAAdhAAOMn5iemgAE7AADjJ6ZnpoAB2EAA4yemZ6ZAATwAAOLnpeemQAHYQADjJ6ZnpoABOsAA46dmZ6aAAdfAAONnpqemQAE7QADjpyZnpkAB2AAA46dmZ6aAATrAAOPnJqdmgAHYAADjpyanpkABOwAA46cmp6ZAAdhAAOMnpmemgAE7AADjJ6anpkAB2AAA4yemp6ZAATsAAONnpmemQANBQAAAAAAAAAAAAAAAA=='
      command_off: 'JgAwAAAEH5+YAAE/mQADqwAEJp2YAAE/mQAGIQAEJJ6YAAFAmAADrAAEI5+ZAAE/mAANBQAAAAAAAAAA=='

PS. Don't forget to add the "==" at the end of the commands. This got me searching for a while.

@RobHofmann Brilliant
with your config I have it working. thanks so much.
how would I send these commands as a script?

Thats a really good question. This is my next step to figure out :).

I'll post back when I know more. With a bit of luck I can spend some time on this later today.

First i created an input_boolean which keeps track of the state of the TV Lift:

bedroom_tv_lift_is_down:
  name: Bedroom TV Lift is down
  initial: off

Next i created 2 scripts which set the input_boolean and do the sending actions to the IR receiver. One script is with a delay (because the lift goes down for 36,5s then has to stop).

tv_lift_down:
  alias: TV Lift down
  sequence:
  - service: input_boolean.turn_on
    data:
      entity_id: input_boolean.bedroom_tv_lift_is_down
  - service: broadlink.send
    data:
      host: 192.168.0.123
      packet:
        - "JgAoAAAEIQAB3ZgABEwABCQAAd+ZAAa/AAQkAAHfmAAETAAEIwAB4JkADQU=="
  - delay:
      milliseconds: 36500
  - service: broadlink.send
    data:
      host: 192.168.0.123
      packet:
        - "JgAoAAADiJ6Yn5kABOsAA46emJ+YAAdhAAOLoJegmAAE7QADjJ+Yn5kADQU=="

tv_lift_up:
  alias: TV Lift up
  sequence:
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.bedroom_tv_lift_is_down
  - service: broadlink.send
    data:
      host: 192.168.0.123
      packet:
        - "JgAwAAAEHqGWAAFBlwADrgAEIaGWAAFClgAGIgAEIqGWAAFBlwADrQAEIqGWAAFBlwANBQAAAAAAAAAA=="

Finally i created a switch using the template switch:

- platform: template
  switches:
    bedroom_tv_lift:
      friendly_name: "Bedroom TV Lift"
      value_template: '{{ is_state("input_boolean.bedroom_tv_lift_is_down", "on") }}'
      turn_on:
        service: script.tv_lift_down
      turn_off:
        service: script.tv_lift_up

Finally i added the switch to my ui-lovelace:

  - icon: mdi:home-floor-1
    title: 1st Floor
    id: first_floor
    cards:
      - type: entities
        title: Bedroom
        entities:
          - switch.bedroom_tv_lift

And as a bonus i decided to add a nice icon to my switch in customize.yaml

switch.bedroom_tv_lift:
  icon: mdi:elevator

Good luck!

PS. Of course i stripped all other non related config from this example. If something is missing or not working, don't hesitate to reply here. Also i translated it from Dutch, so there might be some mistakes :).

For others reading this to try make sesne of it all here is the break down to its simplest form:

In order to have the broadlink.send and broadlink.learn functions you need to add the following to your configuration.yaml file

switch:
  - platform: broadlink
    host: 192.168.0.x
    mac: 'C8:F7:42:xx:xx:xx'

This is the minimum required to get the broadlink unit configured on HA
you can add other info like unit type and friendly name if you want.
To learn commands it is easiest to use a windows program called "Broadlink Manager" (you can google it)
Once you have learnt commands you can add to the original config and add switches such as TV on and off, please note that having == on the end of the command is vital to it working

  - platform: broadlink
    host: 192.168.0.x
    mac: 'C8:F7:42:xx:xx:xx'
    switches:
      lounge_tv:
        friendly_name: Lounge TV
        command_on: 'JgCSAAABIpIWEhYRFhIWNRsx....(truncated).....FhIWNRYSFjUWEhYRFzUW=='
        command_off: 'JgCSAAABJo4WEhYRFhIWERY....(truncated).....hsMFjYWERYSFhEXERYSGg=='

If you dont want switches but prefer to use a list of commands then add the following to your scripts.yaml file:

'lounge_ac_on':
  alias: Lounge AC On
  sequence:
  - service: broadlink.send
    data:
      host: 192.168.0.x
      packet:
        - "JgCSAWNRc1FhIWAABI....(truncated)....FhEWEhYRFxEWNWERcRFjUXzUWAA0FAAAAAAAA=="

you can also combine commands, to change source on my TV i need to press 'input', 'right', 'ok'
this can be lumped together to make things easier:

'tv_change_source':
  alias: Change TV Source   
  sequence:
    - service: broadlink.send
      data:
        host: 192.168.0.x
        packet:
          - "JgBQAAABH5MTEhISFw4TEhISExISEhMSEjcTNhM2EzYTNhM3FQ8TNhMSEzYTEhISEzYTEhMSEhITNhMSEzYWMxMSEjcSNxM2EwAFPwABJkkRAA0FAAAAAAAAAAA="
    - delay:
        milliseconds: 300
    - service: broadlink.send
      data:
        host: 192.168.0.x
        packet:
          - "JgBQAAABIJMTEhISExISEhMSExISEhMSEjcSNxM2EzYTNhM3EhITNhMSEhMSEhM2EzYTEhMSEhITNhM4ETcYDBMSEjcSNxM2FwAFOwABKUYSAA0FAAAAAAAAAAA="
    - delay:
        milliseconds: 300  
    - service: broadlink.send
      data:
        host: 192.168.0.x
        packet:
          - "JgBQAAABIZMTEhMSEhITEhISExISExYOEzYTNhM2FzMSNxI3ExISNxYzEhMSNxISEzYTEhMSEhIXDhI3ExETNxISEzYXMhM3EgAFQAABJEoTAA0FAAAAAAAAAAA="

Massive thanks to @RobHofmann for working out the nitty gritty of it all

Thanks for the clarification! Looks great. I hope people are helped by this :).

For others reading this to try make sesne of it all here is the break down to its simplest form:

In order to have the broadlink.send and broadlink.learn functions you need to add the following to your configuration.yaml file

switch:
  - platform: broadlink
    host: 192.168.0.x
    mac: 'C8:F7:42:xx:xx:xx'

This is the minimum required to get the broadlink unit configured on HA
you can add other info like unit type and friendly name if you want.
To learn commands it is easiest to use a windows program called "Broadlink Manager" (you can google it)
Once you have learnt commands you can add to the original config and add switches such as TV on and off, please note that having == on the end of the command is vital to it working

  - platform: broadlink
    host: 192.168.0.x
    mac: 'C8:F7:42:xx:xx:xx'
    switches:
      lounge_tv:
        friendly_name: Lounge TV
        command_on: 'JgCSAAABIpIWEhYRFhIWNRsx....(truncated).....FhIWNRYSFjUWEhYRFzUW=='
        command_off: 'JgCSAAABJo4WEhYRFhIWERY....(truncated).....hsMFjYWERYSFhEXERYSGg=='

If you dont want switches but prefer to use a list of commands then add the following to your scripts.yaml file:

'lounge_ac_on':
  alias: Lounge AC On
  sequence:
  - service: broadlink.send
    data:
      host: 192.168.0.x
      packet:
        - "JgCSAWNRc1FhIWAABI....(truncated)....FhEWEhYRFxEWNWERcRFjUXzUWAA0FAAAAAAAA=="

you can also combine commands, to change source on my TV i need to press 'input', 'right', 'ok'
this can be lumped together to make things easier:

'tv_change_source':
  alias: Change TV Source   
  sequence:
    - service: broadlink.send
      data:
        host: 192.168.0.x
        packet:
          - "JgBQAAABH5MTEhISFw4TEhISExISEhMSEjcTNhM2EzYTNhM3FQ8TNhMSEzYTEhISEzYTEhMSEhITNhMSEzYWMxMSEjcSNxM2EwAFPwABJkkRAA0FAAAAAAAAAAA="
    - delay:
        milliseconds: 300
    - service: broadlink.send
      data:
        host: 192.168.0.x
        packet:
          - "JgBQAAABIJMTEhISExISEhMSExISEhMSEjcSNxM2EzYTNhM3EhITNhMSEhMSEhM2EzYTEhMSEhITNhM4ETcYDBMSEjcSNxM2FwAFOwABKUYSAA0FAAAAAAAAAAA="
    - delay:
        milliseconds: 300  
    - service: broadlink.send
      data:
        host: 192.168.0.x
        packet:
          - "JgBQAAABIZMTEhMSEhITEhISExISExYOEzYTNhM2FzMSNxI3ExISNxYzEhMSNxISEzYTEhMSEhIXDhI3ExETNxISEzYXMhM3EgAFQAABJEoTAA0FAAAAAAAAAAA="

Massive thanks to @RobHofmann for working out the nitty gritty of it all

Ok, but does broadlink.learn works?
Send is ok but learn is not working.
I am asking because i cannot learn all AC commands via https://keitetran.github.io/BroadlinkIRTools/dist/#/

I couldn't get it working.
I used this to learn commands
https://sourceforge.net/projects/broadlink-manager/

Same. I used the broadlink manager to get the Base64 strings which I used in my send commands.

broadlink.learn doesn't work for me either ;)

I just attempted to.set up my RM mini 3 tonight. I was able to learn a total of 1 command with broadlink.learn, after which homeassistant began serving the same Failed to Connect to device described here.

Same symptoms as the others here: device still works with the app; network is fine; config didn't change; reboots and restarts don't help.

Just seems as if broadlink.learn stopped working.

@johnruemker have you tried broadlink manager, link is a few comments up.
It's easier to use then broadlink.learn
Everyone had given up on broadlink.learn

Thanks for the suggestion. Broadlink manager isn't an option for me right now. I may ultimately have to pursue that to get this setup going, but for now I need to see if I can get broadlink.learn functioning.

To investigate further, I've been attempting to use the broadlink package directly (https://github.com/mjg59/python-broadlink) to interact with my RM mini 3.

I haven't yet been able to learn any commands, but I can at least show that the auth() function works against my device.

I believe auth() is what would be failing within homeassistant's broadlink component to result in the "Failed to connect to device" error, so this result leads me to believe the problem we're seeing must be in the homeassistant broadlink component and not on the broadlink side.

~~~

import broadlink
device = broadlink.rm(('192.168.X.X', 80), 'c8:f7:42:YY:YY:YY', None)
device.auth()
True
device.enter_learning()
device.check_data()
device.check_data()
device.check_data()

~~~

If anyone can figure out the sequence to result in this learning a command, it would serve as a simple workaround to the homeassistant learning problem without needing to use Broadcom [Edit: Broadlink] Manager. As far as I can tell the above commands are the only thing that the broadlink component does for an RM-type device to learn to a command, but its definitely possible I'm overlooking something since I only just started reviewing this code for the first time this morning.

Same issue on broadlink.learn
Failed to connect to device

Same issue here, latest version of HA on Hassio, trying to talk to a RM2 Pro Plus. I managed to get it to work once and learn a single command, after that it never worked again, even after spamming the call service button several hundred times. No idea why mine worked once but I can also confirm the service is otherwise totally broken.

I'm always getting "Failed to connect to device" when I try to use broadlink.learn service with my RM mini 3.
Also, Broadlink Manager in windows is not able to detect my device.
No problem when I send packets, so my RM mini is working, also using e-Control app, but to get IR codes using that app is really annoying and time-consuming! Did you find any solution?

All solutions point to broadlink manager to learn commands. Strange it isn't working for you.
I assume you set the IP correctly in the app?
No idea man.

@Ligio have you tried to switch off windows firewall when you scan with Broadlink manager?
In my case was unreachable until I switched off firewall

I bought one more RM Mini 3 device and with this one, I can connect without any change to my current setup. The difference between the old one is the firmware version:

  • firmware 44057 (connection error)
  • firmware 55 (no problem at all!)

Unfortunately, when I try to check and update the oldest firmware, "ihc for EU" android app says that firmware is already updated and I can't upgrade it to version 55, I don't know why!!!
Is there another way to upgrade the firmware? Or maybe one of my RM Mini 3 is an old version and I can't upgrade it?

I just bought a RM Mini 3 device that came with firmware 44057 and I am getting the same connection error in HA. In Broadlink Manger the device is detected, but no IR commands can be learned (nothing returns, although the light does turn on the device when going into learning mode). In the IHC app on Android no firmware update is available. Is it possible that there are different variants of the device available, and firmware 55 works while 44057 does not? The manual that came with the device references the IHC app (versus the e-control app) so I assume the one I have with firmware 44057 is newer, but I cannot find any dates or other information to support that assumption on the device or the rest of the packaging. For those having this same issue, what firmware does your device have?

+1 here
exactly same issue.
Please help.

I just bought a RM Mini 3 device that came with firmware 44057 and I am getting the same connection error in HA. In Broadlink Manger the device is detected, but no IR commands can be learned (nothing returns, although the light does turn on the device when going into learning mode). In the IHC app on Android no firmware update is available. Is it possible that there are different variants of the device available, and firmware 55 works while 44057 does not? The manual that came with the device references the IHC app (versus the e-control app) so I assume the one I have with firmware 44057 is newer, but I cannot find any dates or other information to support that assumption on the device or the rest of the packaging. For those having this same issue, what firmware does your device have?

I faced the same problem with the unit with FW Version44057, talking to the broadlink China customer support, they quoted there are international version of FW and local China market FW which has no international access. Unit was purchased from taobao equivalent (China seller)

I can't use Google home to do voice control.. Only Wi-Fi local access is working..

In contrast, I have another so called international version that I acquired through local seller is working correctly (it has been upgraded to v55).

My broadlink rm mini 3 also has the same problem, it can only connect locally. It is also on firmware ver. 44057.
Does anyone know how to flash the firmware to v55?

I am having the same problem with latest Home Assistant v0.95.4...

My broadlink rm mini 3 also has the same problem, it can only connect locally. It is also on firmware ver. 44057.
Does anyone know how to flash the firmware to v55?

Same problem here.
I think you can get the v55 from here:
http://fwversions.ibroadlink.com/firmware/download/3727/55.bin

but have no idea of how to upload to try.

The update can be done from the eControl app. In device info there is "Firmware update", if you then click on advanced you can give it the URL to flash whatever you want. I didn't try it as I managed to hack a homekit bridge library to get the codes in a somewhat fast and easy way, and have to warn you that I found an user on Reddit asking for help because he tried to update an rm pro (I believe from the same app, he talks about a generic broadlink app) and bricked the device, so it may be risky...

I tried the Link, unfortunately this returns a 404

The update can be done from the eControl app. In device info there is "Firmware update", if you then click on advanced you can give it the URL to flash whatever you want. I didn't try it as I managed to hack a homekit bridge library to get the codes in a somewhat fast and easy way, and have to warn you that I found an user on Reddit asking for help because he tried to update an rm pro (I believe from the same app, he talks about a generic broadlink app) and bricked the device, so it may be risky...

I tried to upload it using eControl but it just says upload successful but the firmware doesn't change.

I tried the Link, unfortunately this returns a 404

link was wrong. It should be:
http://fwversions.ibroadlink.com/firmware/download/10039/55.bin

The update can be done from the eControl app. In device info there is "Firmware update", if you then click on advanced you can give it the URL to flash whatever you want. I didn't try it as I managed to hack a homekit bridge library to get the codes in a somewhat fast and easy way, and have to warn you that I found an user on Reddit asking for help because he tried to update an rm pro (I believe from the same app, he talks about a generic broadlink app) and bricked the device, so it may be risky...

I tried to upload it using eControl but it just says upload successful but the firmware doesn't change.

I tried the Link, unfortunately this returns a 404

link was wrong. It should be:
http://fwversions.ibroadlink.com/firmware/download/10039/55.bin

Bravo ! Trying to get support from broadlink China is really vomiting blood.

I just wondered why all recent purchased devices failed to get firmware update.

I have 2 RM mini which stuck with this v44057.
One unit used to get offline when my phone is not with house Wi-Fi or on LTE, recently automatically get back remote access capacity but Google home still can't access to it.

The other unit is stuck with this v44057 but no functional issue of Google home access, I am not so concern on this..

Yet to play with home assistant

Just tried to update with that link, same as you... Update successful but still same fw version

For me it actually says the update failed with that new link. At least the link seems to be right.

As a follow-up, I did some investigating using the python-broadlink module and it appears that the issue is the encoding of the response from the device when learning a command. My device on the v44057 firmware sends commands correctly, and when using the learning function data is returned from the device when I hit a key on my remote. That response just cannot be decoded properly by the software as it appears to be formatted differently from what is expected. Unfortunately figuring out how to decode the response is beyond my skill level, but hopefully this helps narrow down the issue.

I have the same problem with RM Mini 3 (v44057), with the same config, RM Pro Plus works fine.
Maybe the problem comes from the command encoding of RM Mini 3 is different from international version, so python module cannot decode/encode

As a follow-up, I did some investigating using the python-broadlink module and it appears that the issue is the encoding of the response from the device when learning a command. My device on the v44057 firmware sends commands correctly, and when using the learning function data is returned from the device when I hit a key on my remote. That response just cannot be decoded properly by the software as it appears to be formatted differently from what is expected. Unfortunately figuring out how to decode the response is beyond my skill level, but hopefully this helps narrow down the issue.

Thanks, this does help. I guess I'll take a look at the library and see what I can do ;)

I opened a PR on the library (mjg59/python-broadlink#255). It seems that the affected edits were made to fix other issues, basically to detect a failed auth, but our rmmini seems to accept the auth and still give out a response without auth key. We'll see how the author wants to handle it, but at least we traced the problem :)

Flashing firmware could be done using Broadlink "e-control" app. Ask device info--> then firmware update --> advanced --> provide for the link.
Sadly for me doesn't work for me on iOS

I found a solution to get the RM3 Link learn command to work. I was trying to run this command, and it wouldn't work:

./broadlink_cli --type 0x27c2 --host 192.168.1.X --mac abcdefg --learn

Then I found this issue on the python-broadlink repo: https://github.com/mjg59/python-broadlink/issues/253

Running pip install cryptography in the venv for the local repo suddenly made the command work. So it basically seems like it's just missing a dependency.

I already had the crypotgraphy lib installed, but I did discover that this is almost certainly caused by v0.11.1 of https://github.com/mjg59/python-broadlink

I was able to find the packets to turn off and on my TV on another HA forum post, and tested that they work through HA without having been learned through broadlink.learn service, which proved that HA could communicate with the device via broadlink.send.

The learn the rest of my IR codes, I downloaded v0.10 of https://github.com/mjg59/python-broadlink (pip3 install broadlink==0.10), and ran the following sequence of command in a python shell:

import broadlink
from base64 import b64encode

devices = broadlink.discover(timeout=5)
devices[0].auth()

devices[0].enter_learning()
# point remote at device to learn code, light will turn off
packet = devices[0].check_data()
b64encode(packet).decode('utf8')

try this:
edit components/broadlink/__init__.py
#auth = await hass.async_add_executor_job(device.auth)
auth = device.auth
My tests worked fine

try this: edit components/broadlink/__init__.py #auth = await hass.async_add_executor_job(device.auth) auth = device.auth My tests worked fine

Excellent finding! This also allowed the learn command to work for me!

FWIW, neither of the previous two comments here helped the problem on my side. I already had cryptography installed, and updating it or downgrading it did not do anything.

I recently bumped to latest and now I got this:

Oct 06 01:11:47 sebbapi hass[1209]: Traceback (most recent call last):
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
Oct 06 01:11:47 sebbapi hass[1209]:     await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
Oct 06 01:11:47 sebbapi hass[1209]:   File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
Oct 06 01:11:47 sebbapi hass[1209]:     return fut.result()
Oct 06 01:11:47 sebbapi hass[1209]:   File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
Oct 06 01:11:47 sebbapi hass[1209]:     result = self.fn(*self.args, **self.kwargs)
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/broadlink/switch.py", line 111, in setup_platform
Oct 06 01:11:47 sebbapi hass[1209]:     broadlink_device = broadlink.rm((ip_addr, 80), mac_addr, None)
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/broadlink/__init__.py", line 529, in __init__
Oct 06 01:11:47 sebbapi hass[1209]:     device.__init__(self, host, mac, devtype)
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/broadlink/__init__.py", line 171, in __init__
Oct 06 01:11:47 sebbapi hass[1209]:     self.update_aes(key)
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/broadlink/__init__.py", line 184, in update_aes_crypto
Oct 06 01:11:47 sebbapi hass[1209]:     backend=default_backend())
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/cryptography/hazmat/backends/__init__.py", line 15, in default_backend
Oct 06 01:11:47 sebbapi hass[1209]:     from cryptography.hazmat.backends.openssl.backend import backend
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
Oct 06 01:11:47 sebbapi hass[1209]:     from cryptography.hazmat.backends.openssl.backend import backend
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 74, in <module>
Oct 06 01:11:47 sebbapi hass[1209]:     from cryptography.hazmat.bindings.openssl import binding
Oct 06 01:11:47 sebbapi hass[1209]:   File "/srv/homeassistant/lib/python3.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 15, in <module>
Oct 06 01:11:47 sebbapi hass[1209]:     from cryptography.hazmat.bindings._openssl import ffi, lib
Oct 06 01:11:47 sebbapi hass[1209]: ImportError: /usr/lib/arm-linux-gnueabihf/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by /srv/homeassistant/lib/python3.7/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so)

I manually compiled and installed python3.7 and openssl-1.1.1 taking several hours...
-rw-r--r-- 1 root root 332080 Sep 27 21:46 /usr/lib/arm-linux-gnueabihf/libssl.so.1.1

env:
Raspberry pi 1B
Raspbian GNU/Linux 9
4.19.66+ # 1253
Hass 0.99.3

Maybe I should consider to open a new dedicated issue.

When will this issue be fixed?

Having installed home assistant in virtualenv, there is no
auth = await hass.async_add_executor_job(device.auth)
in components/broadlink/__init__.py
There is an auth function but nothing like the above in it...
The Failed to connect still here...
(the broadlink lib version is 0.11.1)

@emnik I'm using Home Assistant inside Docker.
After jump to /bin/bash of Home Assistant (docker exec -it home-assistant /bin/bash), my __init__.py file is in:
/usr/src/homeassistant/homeassistant/components/broadlink/__init__.py

I have this issue too, but I understood that is possible to learn commands wiht Broadlink Manager, so now I use the broadlink.send service instead with the raw packets

Edit edit components/broadlink/__init__.py worked for me.
Hassio on pi.
Using this link to access to container source and modify by
vi /usr/src/homeassistant/homeassistant/components/broadlink/__init__.py

Edit edit components/broadlink/__init__.py worked for me.
Hassio on pi.
Using this link to access to container source and modify by
vi /usr/src/homeassistant/homeassistant/components/broadlink/__init__.py

Can ypu please explain me how can I do it, with Hassio?

Thanks a lot in advance!!!

Edit edit components/broadlink/__init__.py worked for me.
Hassio on pi.
Using this link to access to container source and modify by
vi /usr/src/homeassistant/homeassistant/components/broadlink/__init__.py

Can ypu please explain me how can I do it, with Hassio?

Thanks a lot in advance!!!

@lukexperias Please:

  • Enable debugging mode that guided in the link.
  • Access to hassio/pi via port 22222
  • docker exec -it homeassistant /bin/bash
  • vi /usr/src/homeassistant/homeassistant/components/broadlink/__init__.py
  • Modify auth = await hass.async_add_executor_job(device.auth)

Hi all,

I modified my __init__.py for HA as suggested and now it doesn't give the "failed to connect to device" log anymore.
But even if I'm pressing all buttons really close to my RM3 mini it gives me a timeout reading data ;-(

Learning works fine from "IHC for EU" mobile app, so I'm not expecting to be the device or the distance/position I use that break things in HA.

Any ideas ?

Simone

try this: edit components/broadlink/__init__.py #auth = await hass.async_add_executor_job(device.auth) auth = device.auth My tests worked fine

This worked for me too. Thanks! Would you mind submitting a PR for this @GitforZhangXL?

try this: edit components/broadlink/__init__.py #auth = await hass.async_add_executor_job(device.auth) auth = device.auth My tests worked fine

This worked for me too. Thanks! Would you mind submitting a PR for this @GitforZhangXL?

How do I do that? Where do I find the file to be edited?

Well, here's what I did:

Download all the files in this directory: https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/broadlink

Then create a custom_components folder in the same directory as your configuration.yaml. Create a broadlink folder in the custom_components folder and copy the files from above into this folder. Make the necessary change to __init__.py, restart Home Assistant, and you should be good.

Custom components created from an integration override the existing integration.

Well, here's what I did:

Download all the files in this directory: https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/broadlink

Then create a custom_components folder in the same directory as your configuration.yaml. Create a broadlink folder in the custom_components folder and copy the files from above into this folder. Make the necessary change to __init__.py, restart Home Assistant, and you should be good.

Custom components created from an integration override the existing integration.

works flawlessly, learn_command and send_command.
command strings are saved in /config/.storage in a text file.

Hi all,

I modified my __init__.py for HA as suggested and now it doesn't give the "failed to connect to device" log anymore.
But even if I'm pressing all buttons really close to my RM3 mini it gives me a timeout reading data ;-(

Learning works fine from "IHC for EU" mobile app, so I'm not expecting to be the device or the distance/position I use that break things in HA.

Any ideas ?

Simone

Same exact issue here. I'm able to learn commands via the app but not Home Assistant. Connects to the device now after editing the init file but no commands received. Going to try and use Broadlink Manager via a VM on my Mac to see if I am able to get codes that way.

Well, here's what I did:

Download all the files in this directory: https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/broadlink

Then create a custom_components folder in the same directory as your configuration.yaml. Create a broadlink folder in the custom_components folder and copy the files from above into this folder. Make the necessary change to __init__.py, restart Home Assistant, and you should be good.

Custom components created from an integration override the existing integration.

I have the same problem as everyone else and works fine with the Broadlink app. When I create the custom component and modify __init__.py my error changes to "No signal was received" when trying to learn. I didn't try Broadlink manager/send command yet, I am just installing Windows in a VM so will try later.

EDIT: I ended up running Broadlink Manager on my Windows 10 work laptop and I get the same error...

When I try to use Broadlink Manager, I get the following error too.

Found device : Unknown [192.168.1.19]
Writing compatible device not detected!

Someone was talking about finding a mismatch the with device ID due to Broadlink releasing a new device revision... https://community.home-assistant.io/t/broadlink-manager-nicer-way-to-learn-and-send-ir-rf-commands/58770/181

https://github.com/mjg59/python-broadlink/pull/293

I have been trying to understand the protocol here, I understand its using UDP QUIC but its a little over my head and I couldn't match up what I saw in Wireshark with what I read about. Maybe because of the encryption?

There is probably a better way to do this, but I ran the Broadlink app on my iOS device and proceeded to learn a volume up command. Whilst doing so I also ran the app in Android under the BlueStacks emulator on my Mac and fired up Wireshark. I did manage to capture some traffic from the 0x5f36 device to my Mac, no idea if there are any clues in there but the dumps can be downloaded here if anyone wants to take a look:

https://www.dropbox.com/s/0tlgz2y1zrfmt7c/BLink%20Dump%201.pcapng?dl=0
https://www.dropbox.com/s/f1gmycnheqbggwy/BLink%20Dump%20Learn%20vol.pcapng?dl=0

I don't have an older working device to compare it to but I am more than happy to sniff some more traffic from my 0x5f36 device if someone might be able to help me decipher it? I am about ready to gut this thing and stick an ESP in!

@Siytek Thanks for your collaboration. I see a handshake with Broadlink at _556 37.676853_. The IPs involved are 192.168.1.66 and 3.122.136.209. They are using TLS 1.2, so communication is encrypted. The first IP is the local address of your Mac. What intrigues me is that the second IP is not local. So devices are communicating through a cloud. If you access the IP 3.122.136.209 in a web browser this premise will be confirmed: you are communicating with a web service powered by OpenResty.

Thus Broadlink app is cloud based and the data collected won't serve our purpose. We need to capture a direct communication between the computer and the device. I think it will only be possible with e-Control or Broadlink Manager, but apparently these applications don't recognize the device. If someone can make it work with one of these, please send the data for us to analyze.

@Siytek Thanks for your collaboration. I see a handshake with Broadlink at _556 37.676853_. The IPs involved are 192.168.1.66 and 3.122.136.209. They are using TLS 1.2, so communication is encrypted. The first IP is the local address of your Mac. What intrigues me is that the second IP is not local. So devices are communicating through a cloud. If you access the IP 3.122.136.209 in a web browser this premise will be confirmed: you are communicating with a web service powered by OpenResty.

Thus Broadlink app is cloud based and the data collected won't serve our purpose. We need to capture a direct communication between the computer and the device. I think it will only be possible with e-Control or Broadlink Manager, but apparently these applications don't recognize the device. If someone can make it work with one of these, please send the data for us to analyze.

Wow its very interesting @felipediel and thank you for the detailed explanation. I did not try the e-Control app as I also read that people cannot get it to work, but I will try it later this evening.

I also read about a method to capture network traffic from an iOS device so I will try it later too, this should allow me to capture any local packets between the iOS Broadlink app and the RM Mini.

EDIT: I couldn't get the eControl app to work, not sure if its just because its rubbish but it just wouldn't configure the device successfully.

Also you can see the RM Mini local address 192.168.1.121 (_c0 a8 01 79_ starting at byte 20), not sure if its relevant?

0000   60 03 08 a8 14 12 24 df a7 7a 8b 4c 08 00 45 00   `.....$..z.L..E.
0010   00 9c 06 27 00 00 ff 11 31 1e c0 a8 01 79 c0 a8   ...'....1....y..
0020   01 42 00 50 c2 89 00 88 26 97 5a a5 aa 55 5a a5   .B.P....&.Z..UZ.
0030   aa 55 00 00 00 00 e4 07 1c 20 15 01 03 02 00 00   .U....... ......
0040   00 00 0f 02 00 0a 37 97 00 00 dd d2 00 00 00 00   ......7.........
0050   07 00 00 00 00 00 00 00 00 00 00 00 00 00 36 5f   ..............6_
0060   79 01 a8 c0 4c 8b 7a a7 df 24 e6 99 ba e8 83 bd   y...L.z..$......
0070   e9 81 a5 e6 8e a7 00 00 00 00 00 00 00 00 00 00   ................
0080   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0090   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
00a0   00 00 00 00 00 00 00 00 02 01                     ..........

...we need to capture a direct communication between the computer and the device. I think it will only be possible with e-Control or Broadlink Manager, but apparently these applications don't recognize the device. If someone can make it work with one of these, please send the data for us to analyze.

Ok I think I managed to sniff the packets directly between the Broadlink app on my iOS device and the RM Mini 3 using rvictl, it looks more like a usable set of data. Any chance you could take a quick look @felipediel?

Just the learn command: https://www.dropbox.com/s/4z9mxsykp7vs344/Broadlink%20to%20iOS%20cap%20IR%20dump.pcapng?dl=0

Longer capture:
https://www.dropbox.com/s/cz9oxn2wghmeure/Broadlink%20to%20iOS%20dump.pcapng?dl=0

My iPhone IP: 192.168.1.69
RM Mini 3 IP: 192.168.1.121

@Siytek The communication is encrypted, I can't analyze its content. So I will analyze its form.

Let's start at _19 0.0007287_. When you clicked learn command, your phone sent a message to the cloud containing at least the IP address of the universal remote with which you want to communicate (and perhaps a code related to the command learning function).

Then the cloud sent a message to the universal remote stating that your phone wants to communicate. This message does not appear in the log because it was sent directly from the cloud to the remote. It is sometimes possible to intercept messages like this by activating promiscuous mode in Wireshark. Anyway, we can assume that this message existed, because at _21 0.007922_ your phone received a UDP packet from the universal remote and they started to communicate locally.

At _28 0.011493_ and _29 0.011655_, I see two large packets being sent from the remote to your phone. They probably contain the code you just learned.

It is important to note that, although the devices have communicated locally for a while, this was only possible after the triangulation was done by the cloud. Therefore, this data is encrypted and cloud dependent. It does not serve our purpose. But thanks for trying anyway.

By the way, you can configure Wireshark to automatically decrypt incoming packets, but for that you need to have access to the SSL key used in the communication. Don't ask me where to find this one.

@Siytek The communication is encrypted, I can't analyze its content. So I will analyze its form.

Let's start at _19 0.0007287_. When you clicked learn command, your phone sent a message to the cloud containing at least the IP address of the universal remote with which you want to communicate (and perhaps a code related to the command learning function).

Then the cloud sent a message to the universal remote stating that your phone wants to communicate. This message does not appear in the log because it was sent directly from the cloud to the remote. It is sometimes possible to intercept messages like this by activating promiscuous mode in Wireshark. Anyway, we can assume that this message existed, because at _21 0.007922_ your phone received a UDP packet from the universal remote and they started to communicate locally.

At _28 0.011493_ and _29 0.011655_, I see two large packets being sent from the remote to your phone. They probably contain the code you just learned.

It is important to note that, although the devices have communicated locally for a while, this was only possible after the triangulation was done by the cloud. Therefore, this data is encrypted and cloud dependent. It does not serve our purpose. But thanks for trying anyway.

By the way, you can configure Wireshark to automatically decrypt incoming packets, but for that you need to have access to the SSL key used in the communication. Don't ask me where to find this one.

So my understanding from what you have said is that Broadlink have added a cloud-based authorization step and when the app requests a command, the device authenticates it directly with the cloud before opening the communication channel with the app.

Thanks again @felipediel, at the very least it is interesting to have an insight into what is happening and I am sorry I cannot offer more useful input at this stage.

@Siytek Exactly. Thanks for the data, you helped us to better understand the problem.

Hello I am trying to connect my, Broadlink RM Mini3 but I see that nobody got it, right? Should I change my model for another recommendation? Regards

I am looking at the communication again, now with more attention, and I think I was wrong about the triangulation process.

There is definitely a cloud involved, but not needed to control the device. The response at 21 0.007922 refers to the request at 2 0.000292. Therefore, this type of device can communicate locally without intermediation.

For those interested, we're getting close to the solution at https://github.com/home-assistant/home-assistant/issues/23566, but we need help with testing.

For those interested, we're getting close to the solution at #23566, but we need help with testing.

Please let me know how I can help.

Simone

I am looking at the communication again, now with more attention, and I think I was wrong about the triangulation process.

There is definitely a cloud involved, but not needed to control the device. The response at 21 0.007922 refers to the request at 2 0.000292. Therefore, this type of device can communicate locally without intermediation.

For those interested, we're getting close to the solution at #23566, but we need help with testing.

I can do some test

Hi, I just received my RM mini 3 and of course it doesn't work with anything too. Not even with e-Control (saying it's unknown device). If you need some more help testing, let me know.
I have a router with OpenWRT so I can intercept packets directly coming from the internet to the device with tshark.

Hi guys. I need help to test a possible solution, would you mind?

Steps:

  1. Download and run this file.
  2. Wait 5 seconds.
  3. If you see the learning light on the remote, capture a code.
  4. A file called debug.txt will be created.
  5. Send me the file.

Hi guys. I need help to test a possible solution, would you mind?

@felipediel thanks for looking into this. I will run that on my Debian server. I guess the RM has to be on the same subnet right? I have most of my stuff on a separate IoT subnet which is accessible from main LAN through router, but I guess it wouldn't work for the discovery.

EDIT: The python app found the RM (based on the debug), so when I get home to be able to learn a command I will post the file.

@felipediel Alright, I just tried running your code, according to debug log it finds the RM, but the LED doesn't come up and no codes are captured.
Here is the log: https://pastebin.com/g06y6ks0

@InToSSH Thanks for the debug data.
There's definetly a padding problem on encryption.

Let's try ANSIX923 for CBC mode padding.

Steps:

  1. Download and run this file.
  2. Wait 5 seconds.
  3. If you see the learning light on the remote, capture a code.
  4. A file called debug.txt will be created.
  5. Send me the file.

@felipediel No problem :) Thanks for your work on this.
Unfortunatelly this one also doesn't work, same result.
Debug here (in case it's different): https://pastebin.com/3yA0LeKB

@InToSSH Thanks!

Okay, at least now we know exactly where the problem is. We need to find out which CBC mode padding algorithm is being used by Broadlink. It is neither PKCS7 nor ANSIX923, although it looks a bit like this.
No more tests for now. I will keep you informed.

Hi guys. I just packaged the tools I've developed to hack the Broadlink protocol. They still don't have documentation, but I left some examples for you to understand how they work. Now you can easily decrypt, filter and analyze the messages exchanged by the device, whether they come from Wireshark or the debugging tool that I have already made available. Make good use of it and I hope someone can come up with a solution.

@InToSSH Thanks!

Okay, at least now we know exactly where the problem is. We need to find out which CBC mode padding algorithm is being used by Broadlink. It is neither PKCS7 nor ANSIX923, although it looks a bit like this.
No more tests for now. I will keep you informed.

And before anyone is misinformed by this comment, I did a few more tests and maybe the problem is not in the CBC mode padding. But I still think it's worth taking a look at the last byte of the hello response packet. This byte is only active on devices that do not work correctly. And when it is active, bytes 48 to 51 do not carry any information, which can be a clue to the problem.

This issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings