homebridge / homebridge

HomeKit support for the impatient.
https://homebridge.io
Apache License 2.0
24.07k stars 1.99k forks source link

Rm 3 - IR & RF Controller #748

Closed kapps7 closed 6 years ago

kapps7 commented 8 years ago

Wonder if anyone has tried to get this device integrated. Its a cool device which allows a mobile app control any device that uses IR remote e.g.. Home entertainment.

http://www.everbuying.net/product1167543.html

ElBrad commented 8 years ago

Seconded

ericmagnuson commented 8 years ago

AFAIK, the RM3 does not have RF support. Grab the older RM2 if you need RF. I have one, and it rocks. I've just about got it working with HomeKit.

RickNunn commented 8 years ago

@ericmagnuson if you do get it working, let me know. I'd be very very interested.

maragelis commented 8 years ago

@ericmagnuson enlighten us please on how you got this working with homebridge

ericmagnuson commented 8 years ago

@RickNunn & @maragelis, I'd be happy to! I did indeed get it working, but it's a bit of an elaborate setup, so bear with me.

It requires two VMs with network access to the RM2. I used virtualbox, so that's the setup I'll explain. When configuring both of the following VMs in virtualbox, be sure to set the network adapter to Bridge Adapter as seen here.

The first VM (VM1 for short) runs Android-x86 (special flavor of Android for desktop architecture) with the RM Bridge app running. I used the Android-x86 4.4-r4 VMDK image available here. Once you have that VM set up, launch it and install the RM Bridge app by downloading the .apk file from the RM Bridge site. Launch the app and connect to your RM2.

The second VM (VM2 for short) runs *nix, nodejs, and the homebridge app. For the VM, I chose to run Bitnami's pre-built nodejs stack on Ubuntu 14.04. The VMDK image is available at the bottom of the page here. Launch the VM, log in, and install homebridge plus homebridge-http.

Before we get to configuring homebridge, let me take a minute to explain the setup overview. The RM Bridge app on VM1 is what directly talks to your RM2. This RM Bridge app is controlled via an HTTP API. You could build out your own web app to interact with the API, but the RM Bridge creator already wrote some JS tools implementing the RM Bridge API, which are available on the RM Bridge website. Using these RM Bridge tools, you can connect to your RM2, learn remote codes, give them shortcut names, and list the HTTP endpoints that tell RM Bridge to fire the codes.

On VM2, homebridge waits for HomeKit commands (e.g. from your iPhone) and then fires the requested command using homebridge-http to hit the corresponding RM Bridge HTTP endpoint. You will have to set up your HomeKit switches and which RM Bridge endpoints control them in your homebridge config.

This guide is pretty brief, so let me know what areas are confusing, and I will clarify. When I get some more time, I will try to write a more detailed guide (maybe even a screencast) since there really isn’t much out there. Cheers!

RickNunn commented 8 years ago

@ericmagnuson wow you don't mess around. How are you finding the reliability? A screencast sometime would be awesome.

ericmagnuson commented 8 years ago

@RickNunn Haha, I was determined to get it working. The reliability is fairly good but not perfect. Occasionally, I'll have to ask Siri two or three times to turn on a given light if the whole system sits idle too long, but after that, it usually fires just fine (and very very quickly, too).

I've added a detailed guide/screencast to my agenda, so hopefully I can create one in the very near future.

maragelis commented 8 years ago

@ericmagnuson Thanks

cocacola89 commented 8 years ago

Got RM3 working with Homebridge with a much more reliable setup - no VMs whatsoever, just UDP requests from Homebridge directly to RM3. It does require some UDP packet sniffing (which is quite a pain), but once it's done it works like a peach.

ericmagnuson commented 8 years ago

@cocacola89 Sweet! I would love to figure out to reverse engineer the packets, but it'd be a pain. Going through two VMs can be laggy and unreliable at times.

Maybe we could come up with a way to automate the sniffing. How did you go about it? Did you sniff packets from RM Bridge or from the Broadlink app itself?

cocacola89 commented 8 years ago

I sniffed packets from official iPhone e-Control app, but as far as I know RM Bridge uses the same API library from Broadlink (which is distributed in binary form), so it doesn't really make any difference. The real challenge here is to make this API library talk directly to the RM3, as it uses Broadlink cloud service at the highest priority. I had to disable cellular data on my iPhone and pull out WAN cable from my router to achieve this. Sniffing packets from app to the cloud and from the cloud to RM3 is no use - even if you repeat it from Homebridge, RM3 just ignores it. You have to sniff packet that goes directly from API Lib to RM3.

ericmagnuson commented 8 years ago

Hang on, is this compatible with an RM2 or only with an RM3?

cocacola89 commented 8 years ago

@ericmagnuson Sorry, I don't own an RM2, so I can't tell for sure. Furthermore, all discussions I've seen were around RM3. I guess you should try it yourself with RM2, I suspect it will work a-ok.

If you decide to try packet sniffing here are some resources you should see first:

https://community.openhab.org/t/broadlink-black-bean-rm-3-mini-ir-controller-help-with-understanding-their-udp-protocol/ - thread about using RM3 mini with OpenHAB. Some stuff is specifically related to OpenHAB, but this is the place where @davorf has made some good progress on packet sniffing and came up with a DUMMY-REAL workaround.

https://github.com/davorf/BlackBeanControl - simple Python script that sends intercepted payload to RM using DUMMY-REAL workaround. All credits go to @davorf. Unfortunately, I could not get it to work even after intercepting the right packets, so I wrote quite the same app in C# for testing.

https://www.youtube.com/watch?v=YukzDjteE1U - video about integrating RM3 mini with MajorDomo. The video is in Russian, but this guy draws some self-explaining schemas and kinda shows the process of packet sniffing with Wireshark, so it is really helpful. Hope you can use it without knowing Russian :-) This guy doesn't speak about DUMMY-REAL workaround, everything works for him with just real packages, but for me it doesn't.

From my experience:

  1. You should look for UDP packets that go directly from your control app (RM Bridge, official app) to your device, so you should know both IP-addresses.
  2. Do not assign constant IP-address on your router to the RM-device. Just allow it to get first free address via DHCP. (Not quite sure about this, but when I did so, I stopped receiving direct packets).
  3. Sometimes packets show up as QUIC, sometimes as just UDP in Wireshark. Nevertheless, it's full body always starts with 5aa5aa555aa5aa, that sometimes Wireshark interprets as a QUIC-header.
  4. 5aa5aa555aa5aa is always followed by 55000000000000000000000000000000000000000000000000 in the packet payload. That's a clue when searching for the right packets.
  5. Full packet payload is quite long. For instance, my dummy packet payload is 5aa5aa555aa5aa5500000000000000000000000000000000000000000000000022f4000037276a007a805220cc0d43b401000000c9c60000bd3c65d3423957f33f5d27c067e72bff6fe7d6f3fc7d1b24d7926df1fb5de67a4a05d20c9c5b0fc19fd7aa4de3cb99b63b42b9f8ec238ab8841db108b7b95585d8e0092675b4a1c684db179ac8d99c57. Anything much shorter than this is ignored when you try to reproduce it.
  6. Once you capture the right packets and successfully repeat it (with DUMMY-REAL workaround or without it) you could power off and back on your RM-device, it will still work. However, if you reset your device it stops working.
  7. I don't own an Android device and RM Bridge does not support RM3 mini, so I had to sniff packets from official iPhone app. It is a real pain. Official app always tries to send commands via Broadlink cloud and not locally (even if it shows local icon next to your device). Another problem is sniffing Wi-Fi traffic between iPhone and RM-device. Luckily, my router supports sniffing on a particular interface and exporting results in Wireshark format. If you own a rooted Android device or got RM Bridge working I would recommend you to sniff traffic via some Android apps, I believe it'll be much easier.

Hope this could help. Don't forget to share your experience, this could help in further research.

ericmagnuson commented 8 years ago

Wow, thank you so much for taking the time to write all that info. I am thinking that it might be possible to cut out RM Bridge in my setup. I will do some research and get back to this thread.

Yannik25 commented 8 years ago

I also bought a RM3 and wanted to sniff the packets, today i saw this in tindie: maybe it will be less work to implement? https://www.tindie.com/products/harik/zmote-wi-fi-universal-remote/

ericmagnuson commented 8 years ago

Oh, that looks pretty cool! Unfortunately it won't work for my use because it doesn't support RF. :(

ericmagnuson commented 8 years ago

Bad news: My screencast is on hold.

Good news: It's on hold because I've found a way better way to build this whole setup.

Instead of needing to run an Android emulator/VM for RM Bridge, I'm building a python app to do the same(ish) thing.

  1. It will be faster and more lightweight.
  2. It will be more reliable.
  3. It will have its own front-end for managing codes.
  4. It has an open API that Homebridge (and other apps) can plug in to.
  5. Because it's only python, it can be run in almost all situations on the same machine/VM as Homebridge.

Unfortunately, it doesn't support RM3s yet, but I'm hoping someone can help build that in once I post the code.

RickNunn commented 8 years ago

Awesome

flyingartichoke commented 7 years ago

@ericmagnuson - any chance you'd be able to share your python app for linking Homebridge to a Broadlink remote?

I've gone pretty far down the path of VMs and Android emulators and, though I'm close to getting it working, I would really love to scrap it for something simpler like you've described! Having multiple machines and operating systems running 24/7 to link these two systems is quite cumbersome!

ericmagnuson commented 7 years ago

@flyingartichoke Certainly. I've added it to my to-do list for this week. I'll throw it up in its own repo and notify everyone here when that happens.

Those were exactly my thoughts with making the python app. Wanted to have something a bit more reliable and snappier (and I think it does a good job at that). I haven't been able to test Homebridge integration lately because my Home app on my iPhone hangs on load in the iOS 10.2 betas, but theoretically it should work just fine using homebridge-http or homebridge-httpmulti. I also wrote a simple web interface for the python app, too.

ericmagnuson commented 7 years ago

Alright, everyone, I just pushed my project, RM Control, onto GitHub. Check it out.

I'm still working on developing the readme.md, so bare with me. If you have any questions or feedback, don't hesitate to leave an issue on the repo's page — it'd really help know where I need to improve things.

Finally, huge credit/appreciation/thanks/shoutout goes to @mjg59 for their python-broadlink library. It powers the backbone of RM Control, allowing my app to communicate with the RM device directly.

lprhodes commented 7 years ago

I've created http://github.com/lprhodes/homebridge-broadlink-rm which supports RM3 and RM Mini 3 - possible others but I've no way of checking. There's support for toggle switches, channels and a thermostat service that tries to work around not getting IR feedback about mode/temperature from the air condition.

It also has a a dedicated accessory for learning IR codes and outputting them to the home bridge console so people can avoid using Wireshark.

lprhodes commented 7 years ago

@ericmagnuson I've been sold an RM and its listing stated RF but I'm struggling to get it working for RF and you said you don't believe the RM3 has RF. I can't find any info on it not having RF, how did you know that it doesn't?

lprhodes commented 7 years ago

...update on the RM3 not having RF...it does have RF but the antenna is built into the board.

jeylites commented 7 years ago

I see lots of RM3 support, what about RM2 does this build support it?

lprhodes commented 7 years ago

@jeylites https://github.com/lprhodes/homebridge-broadlink-rm does yes

jeylites commented 7 years ago

@lprhodes That is awesome! does it support RF signals as well? If so how is it listed on config- Json. I notice you have a bunch of IR codes listed as accessories.

joq3 commented 7 years ago

@ericmagnuson I have two codes which I have been using successfully with the broadlink homebridge earlier. Now I am switching to Home Assistant, and according to their guide there is a quite troublesome way to get the codes. https://home-assistant.io/components/switch.broadlink/ I tried the codes I have since before, and they do not work, and they don't look anything like the samples provided in the link. Do you think it is possible to convert the codes I have to be able to use with Home Assistant? This is one of the codes:

5aa5aa555aa5aa550000000000000000000000000000000000000000000000000ceb000037276a00918122a2f00d43b401000000efc600006c163e70a1e04b6a065b73f81bcb0c5f04fc1c5f191f55c661a7d2a98f494095bd462e80cc9d75165689013d5127ff2d53d083a83b9f0b1de71c033f6c9e8dbfcc908b248c29a0826227a76768748c66 and this is the other 5aa5aa555aa5aa5500000000000000000000000000000000000000000000000008fb000037276a00ba8122a2f00d43b40100000049c700007fe07e9366ed41bbfe2ee81cb7ad029e41a7b6d05b19471f128220424fc85d5af65dcdf318063442129f01ed48038a89e29767f5c4bcb2bade53ea37de738fc0db3544f9ab82b61cd6aa6bde47f5c971448c25e55e83b85c0bc895c5a69486f4

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity, and will be closed if no further activity occurs. If this issue was overlooked, forgotten, or should remain open for any other reason, please reply here to call attention to it and remove the stale status. Thank you for your contributions.