Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to connect to device (Broadlink RM Mini3) #23566

Closed
shokwaav opened this issue Apr 30, 2019 · 89 comments
Closed

Failed to connect to device (Broadlink RM Mini3) #23566

shokwaav opened this issue Apr 30, 2019 · 89 comments

Comments

@shokwaav
Copy link

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.

@bru73f0rc3
Copy link

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.

@RobHofmann
Copy link

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

@shokwaav
Copy link
Author

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?

@RobHofmann
Copy link

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

@shokwaav
Copy link
Author

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

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

@wzwick
Copy link

wzwick commented May 19, 2019

+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.

@foobarjimmy
Copy link

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

@someguythatcodes
Copy link

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

@RobHofmann
Copy link

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

@wzwick
Copy link

wzwick commented May 22, 2019

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.

@RobHofmann
Copy link

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.

@wzwick
Copy link

wzwick commented May 22, 2019

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

@wzwick
Copy link

wzwick commented May 22, 2019

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.

@someguythatcodes
Copy link

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.

@RobHofmann
Copy link

RobHofmann commented May 22, 2019

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.

@wzwick
Copy link

wzwick commented May 23, 2019

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

@RobHofmann
Copy link

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.

@RobHofmann
Copy link

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 :).

@wzwick
Copy link

wzwick commented May 26, 2019

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

switch
  - 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

@RobHofmann
Copy link

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

@Nomeboj
Copy link

Nomeboj commented Jun 2, 2019

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

switch
  - 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/#/

@wzwick
Copy link

wzwick commented Jun 3, 2019

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

@RobHofmann
Copy link

RobHofmann commented Jun 3, 2019

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 ;)

@johnruemker
Copy link

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.

@wzwick
Copy link

wzwick commented Jun 4, 2019

@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

@johnruemker
Copy link

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.

@johnruemker
Copy link

johnruemker commented Jun 4, 2019

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.

@sitnikovalex
Copy link

Same issue on broadlink.learn
Failed to connect to device

@DoctorOctagonapus
Copy link

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.

@Vinz87
Copy link

Vinz87 commented Dec 30, 2019

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.

@creemerica
Copy link

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.

@Siytek
Copy link

Siytek commented Jan 23, 2020

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

mjg59/python-broadlink#293

@Siytek
Copy link

Siytek commented Feb 3, 2020

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!

@felipediel
Copy link
Contributor

@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
Copy link

Siytek commented Feb 4, 2020

@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                     ..........

@Siytek
Copy link

Siytek commented Feb 4, 2020

...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

@felipediel
Copy link
Contributor

@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
Copy link

Siytek commented Feb 5, 2020

@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.

@felipediel
Copy link
Contributor

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

@Luisiado
Copy link

Luisiado commented Feb 6, 2020

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

@felipediel
Copy link
Contributor

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.

@chemelli74
Copy link
Contributor

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

@robons17
Copy link

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

@InToSSH
Copy link

InToSSH commented Feb 25, 2020

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.

@felipediel
Copy link
Contributor

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.

@InToSSH
Copy link

InToSSH commented Feb 26, 2020

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.

@InToSSH
Copy link

InToSSH commented Feb 26, 2020

@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

@felipediel
Copy link
Contributor

@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.

@InToSSH
Copy link

InToSSH commented Feb 26, 2020

@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

@felipediel
Copy link
Contributor

felipediel commented Apr 19, 2020

Fixed in #32523.

@markheloking
Copy link

This issue can be closed.

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests