BroadLink Mark II plugin

A BroadLink Mark II plugin to try out.

The code can be found on GitHub here:

  https://github.com/a-lurker

You can install the plugin from the ‘Alternate App Store’, which works together with the ‘ALTUI’ plugin:

  https://community.getvera.com/t/altui-alternate-app-store/192721

Note that ‘ALTUI’ is highly recommended to all users, together with openLuup.

Caveats:
Only tested on the RM3 Pro 2 device. While other devices may be discovered, they might not work. This plugin is based on information from here:

The reverse engineering is ongoing. Consequently it may not be possible to have all functionality operational until that process is complete.

If the LED on your device flashes when you transmit a code, the plugin is working. It’s a different matter whether you have the correct code or not. Many learnt codes have excessive replication and some codes are not replicated enough. ie some TVs, etc require a code to be sent two or three time, in close succession, for them to work. I propose not to engage in discussions on why your codes work or not. See this link instead:

Logging can be enabled by setting the DebugEnabled flag to ‘1’. You can use AltUI plugin to look at the log file:

See Misc–>Os Command–> Tail Logs Tab Note: you can change the 50 to say 500 to see more log info.

In openLuup use the console logs:

http://<openLuup_ip_address>:3480/console?page=log

Or use the infoviewer plugin. Please provide a log file with any bug reports, otherwise the report may not be responded to.

What the plugin will do:

  1. BroadLink and ProntoCodes can be used.

  2. The one instance of the plugin can (in theory) handle multiple BroadLink physical devices. The plugin will produce child devices as necessary, based on the capabilities of each BroadLink device discovered. eg a Broadlink Rm Pro will have a temperature and IR child device associated with it.

  3. BroadLink WiFi operated switches such as the SP1 & SP2 & SC1 should work but the MP1 may need work - I haven’t been able to test this.

What the plugin will not do:

  1. Wall switches operated locally will provide on/off status but the update period in the UI will be long (minutes) ie not instant status
  2. The plugin does not interact with the “e-Control” phone app in any way. However e-control codes can be converted for use with the plugin - refer to:
    http://forum.micasaverde.com/index.php/topic,53871.msg380629.html#msg380629
  3. The plugin doesn’t store IR or RF codes - codes need to be applied to the IR child.

Potential problems:

  1. RF codes may or may not work. Haven’t tried it.

  2. Getting codes: As I understand it you can download codes held by the “e-Control” app ie: in the file eControl-data.zip I haven’t tried this. Presumably the “e-Control” app needs to be running on the phone and you get the codes by entering in your browser this link - note: insert the phone’s ip address:

http://<PHONE_ip_address>:48815"

If some one can post the file proffered, that would be good, as I would like to review its contents - especially any file containing codes for 315 MHz, as well as 433 MHz, as I haven’t be able to check RF code functionality.

  1. Your router blocks UDP broadcast traffic - that will cause problems - read your router manual!

  2. The BroadLink devices are identified by their MAC addresses. If you change the IP address of a BroadLink device for any reason, you need to restart the Luup engine. The new ip address will be discovered and used.

  3. After a Vera Luup engine restart, there is 85 second delay before the plugin starts polling, then it polls at minimum of every five minutes. So temperatures, etc are updated at this rate.

  4. Some BroadLink devices can control remote devices on 315 MHz, as well as 433 MHz. Some just allow 433 MHz (country based). The box the unit is delivered in, says what it contains. I’m unsure how this can be detected programmatically.

Usage:
Sending a ProntoCode:
luup.call_action(‘urn:a-lurker-com:serviceId:IrTransmitter1’, ‘SendProntoCode’, {ProntoCode = ‘your code here’}, DeviceID)

Sending a BroadLink IR or RF code:
luup.call_action(‘urn:a-lurker-com:serviceId:IrTransmitter1’, ‘SendCode’, {Code = ‘your code here’}, DeviceID)

Using AltUI; codes can be cut & pasted into the actions for easy testing.

This post provides an understanding how the IR devices should be used (using a GC100 device):
http://forum.micasaverde.com/index.php/topic,29685.msg234078.html#msg234078

Ver 0.51
Initial release.

This plugin has been tested using the AltUI plugin and the Vera UI7 interface with Firefox 57.0.2. It works with openLuup and on a Vera 3. UI5 may work.

Ver 0.52
The plugin can now learn codes. It works pretty well for IR codes but is a bit suspect when learning RF codes. To start the learning process issue these commands to the appropriate child device (not the parent):

luup.call_action(‘urn:a-lurker-com:serviceId:IrTransmitter1’, ‘LearnIRCode’, {}, DeviceID)

luup.call_action(‘urn:a-lurker-com:serviceId:IrTransmitter1’, ‘LearnRFCode’, {}, DeviceID)

The LED will light up on the BroadLink device and you have about 30 seconds to learn the code. For IR codes just tap the remote button. For RF codes it’s more complicated. Once learning starts hold the remote button down for about four seconds (this gets the frequency). Wait a second and then tap the remote button (this gets the code). This sequence is not easy to do and codes may not be learnt or may be incorrect.

The parent device (not the child device) reports the learnt codes in “LearntIRCode” and “LearntRFCode” as seen under the variables tab. If a code is not learnt then the variable reports “No IR code was learnt” ditto for RF codes.

Ver 0.53
General bug fixes and support for BroadLink WiFi switches. If your switch doesn’t work then provide logs. The MP1 four switch may need more work - provide logs.

Note RF code learning is a work in progress and may not function as desired.

Ver 0.54
Note: a JSON module is now required to be available to the plugin. This will mostly effect UI5 users as UI7 has one already available. If one is not found, you will be notified in the UI top banner at Luup engine start up. Refer to this post for a suitable module:

http://forum.micasaverde.com/index.php?topic=29989.0

Fixes a bug whereby if a device was offline and a Luup Engine restart occurred and subsequently the device went on line and another Luup Engine restart occurred; then the device’s children would be deleted then recreated with new device IDs.

Measured temperatures can now have an offset applied. It’s a crude approach to correction but may help those interested. In general expecting sub one degree Centigrade accuracy (or even two degree) from the BroadLink Pro(s) is probably overly optimistic.

Also misc general bug fixes.

Existing users just need to upload the “L_BroadLink_Mk2_1.lua”.

Ver 0.56
Improved RF learning. More recent devices recognised and catered for.

Thanks a-lurker for doing this, it will get a lot of people out of a hole that they have been stranded in.

I’ll trial it with a spare RMPro2 and report back, although I don’t use Alt UI, I hoping that it will use UI7?

Thanks a-lurker this is really amazing. I’m using an RM Mini3 and it appears your scripts found it and labeled it “RM Mini - IR 1”, but when I go to Actions and send a code I don’t see the light on the device. Was their a step I missed in setup that would cause this to happened? I did not pair it using your scripts as it was already on the network my Vera is on. Thanks for any help you can provide.

Was their a step I missed in setup that would cause this to happened?
All sounds OK to me. Post the IR code you are trying to send and I'll try it out here. And the debugging in the log is always worth a look.

Maybe a silly question but can the new broad link units control 433mhz units (blind motor)?

can the new broad link units control 433mhz units (blind motor)?

Don’t know for sure but it seems very likely. Given the Broadlink device is so inexpensive and if it didn’t work for your blinds; you would still have an IR transmitter you could use. Give it a try?

I see also that some Dooya products support the Broadlink protocol directly:

[size=1em]This may answer the question, copied from the below thread which has now been locked.[/size][size=1em]
Re: PLUGIN: Broadlink RM Interface
? Reply #141 on: 29 December 2017, 05:50:49 ?

i have used the pluging with RF devices and works very well, in case of the RF, you need to import the devices from the e-Control APP.

in order broadlink learn a RF you need to go to “user-defined” then go to Sweap Frequency option

[/size]

Yes - it looks like the reverse engineering of the RF learn process needs more work. Hence the need to get them from e-control.

On the plus side; I now have the MK2 plugin learning IR codes. Code will be in version 0.52 (not on GitHub yet).

2) Getting codes: As I understand it you can down load codes held by the "e-Control" app ie: in the file eControl-data.zip I haven't tried this. Presumably the "e-Control" app needs to be running on the phone and you get the codes by entering in your browser this link - note: insert the phone's ip address:

http://<PHONE_ip_address>:48815"

If some one can post the file proffered, that would be good, as I would like to review its contents - especially any file containing codes for 315 MHz, as well as 433 MHz, as I haven’t be able to check RF code functionality.

Any one got a zip file with RF codes?

Can your PI run from Vera?
I do have AltUI on a UI5 machine, but have problems on UI7 with the altUI PI and Appstore (get a failure message) so am unable to try it out.

[quote=“a-lurker”]

can the new broad link units control 433mhz units (blind motor)?

Don’t know for sure but it seems very likely. Given the Broadlink device is so inexpensive and if it didn’t work for your blinds; you would still have an IR transmitter you could use. Give it a try?

I see also that some Dooya products support the Broadlink protocol directly:

https://github.com/mjg59/python-broadlink/commit/82172f54ab722fb9de998d0ae4c24337e41d5787[/quote]
Thanks for the info,
I wish I had found this flexible device earlier as I have just added 2x global cache flex wifi device at more cost that one of these and a mini:-/ and also just ordered a rfxcom USB unit for 433mhz:-(

Any chance to work with Broadlink SC1 (tcp/udp wifi relay control box) ?

@stefanradu5

I haven’t got a SC1, so I can’t test it but I think the plugin can be made to work it, given the correct info. At a minimum turn it off and on. Not so sure about reading its status or anything else that it might do.

I haven’t been able to find its internal device ID (on the internet that is) but the plugin should be able to determine it. If you install the plugin from the code in GitHub (ver 0.52 that I have just updated to-day. see next post) and with the SC1 running on the LAN: then once the plugin is installed then: do a Luup engine restart and in the log you should see:

[code]50 02/06/18 13:38:34.757 luup_log:151: BroadLink_Mk2 debug: Initialising plugin: BroadLink_Mk2 <0x2b833680>
50 02/06/18 13:38:34.758 luup_log:151: BroadLink_Mk2 debug: Using: Lua 5.1 <0x2b833680>
50 02/06/18 13:38:34.758 luup_log:151: BroadLink_Mk2 debug: 0.52 → PluginVersion <0x2b833680>
50 02/06/18 13:38:34.762 luup_log:151: BroadLink_Mk2 debug: xxx.xx.xx.xx <0x2b833680>

50 02/06/18 13:38:34.805 luup_log:151: BroadLink_Mk2 debug: xxx.xx.xx.xx <0x2b833680>
50 02/06/18 13:38:34.807 luup_log:151: BroadLink_Mk2 debug: Rx’ed a discovery response: rxMsg length = 128 <0x2b833680>

128 lines of log here with the Rx’ed message values and then this message:

The BroadLink device at IP address %s and of type 0x%04x is not known to this plugin
[/code]

I need to know the hex reported in the message above as a starting point. It represents the BroadLink SC1 that is on your LAN. Note the various methods to get access to the log are explained widely in this forum.

Ver 0.52 - see first post - now allows code learning.

I have not fully understand how to install this plugin.
I installed AltUI (with some problems) … but it works on a modified link (Vera plus) …<my_local_ip>/port_3480/…
I installed App Store for AltUI
Updated AltUI and App Store…
Try to search for Broadlink Mark II and didn’t find it in app store.
I am beginner with vera…

I’ve not set up the plugin in the ‘Alternate App Store’ - as noted in my original post. Note that devices can be installed manually by just uploading the files and entering the correct info into the correct boxes. Refer to forum. However I will endeavor to get the plugin into the ‘Alternate App Store’ asap.

Ver 0.53a for stefanradu5 attached. Edit - attachment removed.

@zedrally

Can your PI run from Vera? I do have AltUI on a UI5 machine, but have problems on UI7 with the altUI PI and Appstore (get a failure message) so am unable to try it out.

Whoops - after re reading this I realised that you were talking about the plugin (PI) whereas I thought you were talking about a RasPi and openLuup :o and had posted your message in the wrong thread. Anyway; answer is yes. You can install it using Vera UI7 to manually install the files and to then create the device.

Ver 0.53 uploaded to GitHub - see first post.

Is there a way to correct the temperature sensor for a Broadlink RM Pro?
I bought a second Broadlink RM pro and i find a difference in temperature reading of 0.8 - 1 degrees in Celsius.
If I have no option I will have to return and replace the new unit.
The first one bought from the same company is almost accurate…

I would think that these sort of differences are fairly typical. So for example the commonly used (not sure what BroadLink use) DS18B20 sensor are +/- 0.5 degrees C : https://cdn.sparkfun.com/datasheets/Sensors/Temp/DS18B20.pdf

In addition the temperature inside an electronic case tends to be higher than the ambient temperature depending on the power dissipation of the electronics. Not so bad for say the low power BroadLink device but for example the temperature sensors in mobile phones nearly always read high.

Plus a slight breeze in one location compared to another will change the readings.

If you are really concerned, there is a maths plugin somewhere that may help.

Have you kept the SC1 or didn’t that work out?