Broadlink RM-PRO and A1 sensor

Hi,

I have RM Pro and the black bean working with HA! Thank you for the implementation. I just want to ask how to implement the MP1 since its already supported by https://github.com/mjg59/python-broadlink/blob/master/broadlink/init.py#L49. How can I make it work with the current version of HA (36.1) ? sorry newcomer here.

Thank you guys!

Someone have to add support for it in HA, before it can work.

GETTING E-CONTROL REMOTES ON HA

First get or learn all the remotes you want to add on HA in E-CONTROL

  1. download script from https://github.com/NightRang3r/Broadlink-e-control-db-dump

  2. open the e-control app and on the left side menu choose “Share” and then “Share to other phones in WLAN” it should generate the files you will need on the script.

  3. Connect your Android device to your computer and browse the SD card / External Storage folder “/broadlink/newremote/SharedData/” You need to get the following files:
    jsonSubIr
    jsonButton
    jsonIrCode
    and put them in the same folder as this script.

  4. Install Requirement: simplejson
    pip install simplejson

  5. Navigate to the fold you have downloaded and run:
    python getBroadlinkSharedData.py
    Follow the screen steps.

  6. Install python broadlink library:
    git clone https://github.com/mjg59/python-broadlink.git
    (navigate to folder you downloaded)
    sudo python setup.py install

  7. Test the codes you got by using sendcode script you have already downloded.
    You need to edit the script with your RM Pro IP Address and MAC Address and with the code in hex format.
    When run the script, you know the code works when get message
    Code sent…
    Not every code works.

  8. Convert the working HEX codes to Base64 here: http://tomeko.net/online_tools/hex_to_base64.php?lang=en
    and use on HA.

2 Likes

Great, could you add that to the documentation https://home-assistant.io/components/switch.broadlink/ ?

yes, I will just wait for someone test to ensure the steps are clear and complete…

1 Like

Hi,

I tried this with my TV and Aircon as far as i can tell its working! thank you for the detailed instructions!

Hi,

I manage to locate and use a simple python script to turn off and on the MP1 switch.

I git clone https://github.com/mjg59/python-broadlink.git then cd to the folder. Installed the script and created a python script for turning on off the four socket of the MP1 switch

#!/usr/bin/python

import broadlink
import time
import sys

devices = broadlink.mp1(host=("IP_MP1",80), mac=bytearray.fromhex("MAC_MP1"))
print "Connecting to Broadlink device...."
devices.auth()
time.sleep(1)

#print devices.check_power()
#print "Check State"

#ON S1 - S4
print devices.set_power(1, True)
print "S1 On"

print devices.set_power(2, True)
print "S2 On"

print devices.set_power(3, True)
print "S3 On"

print devices.set_power(4, True)
print "S4 On"


#For Off
print devices.set_power(1, False)
print "S1 Off"

now can I can use HA to excuse the python script to turn the individual socket on and off ??
How can I implement it so at i can use it through HA in the meantime until it will be supported.

Thanks!

Why not implement it directly in Ha?

Here is the file you need to modify https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/switch/broadlink.py

Hey guys, I’m completely at a loss. Ever since upgrading to the latest HA, the broadlink package fails to install.
This is something that has to do with pycrypto, even though it is installed. The broadlink package already worked for me, but since upgrading, it won’t install.

Here is the error which shows up in the console:

INFO:homeassistant.util.package:Attempting install of broadlink==0.3
Command "C:\Users\admin\AppData\Local\Programs\Python\Python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\admin\\AppData\\Local\\Temp\\pip-build-yett7vfx\\pycrypto\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\admin\AppData\Local\Temp\pip-6ou8758a-record\install-record.txt --single-version-externally-managed --compile --home=C:\Users\admin\AppData\Local\Temp\tmphdk_7zdj" failed with error code 1 in C:\Users\admin\AppData\Local\Temp\pip-build-yett7vfx\pycrypto\
ERROR:homeassistant.bootstrap:Not initializing switch.broadlink because could not install dependency broadlink==0.3

I’ve managed to run the command manually to see the internal error. Here is the output:

py -u -c "import setuptools, tokenize;__file__='C:\\Users\\admin\\AppData\\Local\\Temp\\pip-build-yett7vfx\\pycrypto\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\admin\AppData\Local\Temp\pip-fwz4aw1j-record\install-record.txt --single-version-externally-managed --compile --home=C:\Users\admin\AppData\Local\Temp\admin\"
running install
running build
running build_py
error: package directory 'lib\Crypto' does not exist

After completely being lost, I decided to try a fresh start and installed HA on a brand new machine, and I still run into the same problem.
I’m running on Win10, Python 3.5.2 / 3.5.3 (tried both), HA 0.36.1.
Installed pycrypto from here:

Any ideas?
I’m completely desperate about this.

after upgrade its start to work but I have switch that is not in my configuration and I can’t delete it??? see the picture red mark.

Have you read this: https://home-assistant.io/components/sensor.broadlink/#microsoft-windows-installation ?

Hi Daniel, thanks for the help.
Yes, I’ve read it thoroughly and performed all of the actions, it still fails to install the component.
As I’ve mentioned, I’ve even installed HA from scratch on another PC - I still run into the same problem.
Any other ideas?

Install linux :slight_smile:

1 Like

That’s a terrible idea :stuck_out_tongue_winking_eye:

I’ve managed to find the problem, now I just need to figure out where to fix it.
When HomeAssistant installs the broadlink package, it runs the following command:

py -u -c "import setuptools, tokenize;__file__='C:\\Users\\admin\\AppData\\Local\\Temp\\pip-build-yett7vfx\\pycrypto\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\admin\AppData\Local\Temp\pip-fwz4aw1j-record\install-record.txt --single-version-externally-managed --compile --home=C:\Users\admin\AppData\Local\Temp\admin\tmp_ohv5jag6"

But it runs it a wrong location, notice the parameter:
home=C:\Users\admin\AppData\Local\Temp\tmp_SOME_RANDOM_GUID
when in fact it needs to run from:
home=C:\Users\admin\AppData\Local\Temp\pip-build-SOME_RANDOM_GUID\pycrypto

Do you have any idea where I could find the code that runs this command so I could fix it?

Thanks for your detailed steps, been trying to follow them. I have manage to get to #5 and then I am not getting a result. When I check the code I am getting the following error:

line 27, in
jsonSubIrData = json.loads(jsonSubIr)
NameError: name ‘json’ is not defined

I am running Python 2.7.13. I am no expert, any help would be great.

Hi, i know nothing about python as well, but I found something interest and could help.

I got simplejson installed on python3.5 site_packages as shown when just tried install again with pip install simplejson

You will get a message saying requirement already satisfied in (path) and when you run just python it call python 2.7 (witch has no simplejson installed)

If you call by python3.5 the script gives another error…

But if you install simplejson with this command:
sudo easy_install simplejson

you get it installed on python2.7 (as least I got it)
and then I got it working…

So, just try installing simplejson that way and remember to go to the broadlink files foldes before run the script.
Tell me if worked…

Thanks again for the pointers, I have tried with both installation with 2.7 and I haven’t been able to get it to work. As of python 3.4, pip is bundled with the python installer for Windows, so I went back and tried it with 3.6. and I’m getting the following error:
, line 20, in
import simplejson as json
ModuleNotFoundError: No module named ‘simplejson’

Might be getting somewhere. In file “getBroadlinkSharedData.py” I replaced “import simplejson as json” with “import json” in 2.7.

Think it’s working thanks.

2 Likes

Just to confirm I have it working, currently just set up with 5 RF wall plugs. Took a bit of figuring out what marries up with what but now it is working great. Better than RM bridge IMHO. :grinning:

2 Likes

Can you share the config. I have been trying to add RM Pro to HA but no luck.I have 5 433MHz outlets configured on RM Pro.