BroadLink Mark II plugin

Just to check

  1. in ALTUI->Devices->control panel for Broadlink RM4 Pro device, should I have had some devices appear or is that what I am trying to get to?
  2. For trying to learn IR codes do I use the Broadlink app on my phone and then check the logs in ALTUI or use the broadlink_cli? (any examples?)

Looks a lot better. The flashing of the LED on the device generally reflects if it’s in AP mode or doing something else.

Below are examples of the three method of sending an IR code, that can be executed in the Lua test window. Note you must insert the ID of the IR child device, not the ID of the parent. You should see a LED flash when the code is run. Try the ProntoCode first:

Examples:

Send a ProntoCode:

local deviceID = 164
local prontoCode = '0000 0067 0000 0010 0060 0018 0018 0018 0030 0018 0018 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0018 0018 0018 0018 0018 0018 0030 0018 0030 0018 0018 0018 0018 037E'

luup.call_action('urn:a-lurker-com:serviceId:IrTransmitter1', 'SendProntoCode', {ProntoCode = prontoCode}, deviceID)

return true

Send a BroadLink IR or RF code:

local deviceID = 162
local rfCode = 'b2 06 1c 00 0c 0e 0f 1a 1b 0f 0f 1a 0f 1a 0f 1a 0f 1a 0f 1a 0f 1a 0f 1b 1a 0f 1b 0f 1b 00 02 5d 00 00 00 00 00 00 00 00 00 00 00 00'

luup.call_action('urn:a-lurker-com:serviceId:IrTransmitter1', 'SendCode', {Code = rfCode}, deviceID)

return true

Send a BroadLink IR or RF code extracted from the e-Control app:

local deviceID = 162

-- Note the usage of curly brackets/braces. You can also leave 
-- the curly brackets off and use quotes, instead passing the
-- info in as a string, rather than as an array.
local rfCode = {-78,  6, 28, 0, 12, 14, 15, 26, 27, 15, 15, 26, 15, 26, 15, 26, 15, 26, 15, 26, 15, 26, 15, 27, 26, 15, 27, 15, 27, 0, 2, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

luup.call_action('urn:a-lurker-com:serviceId:IrTransmitter1', 'SendEControlCode', {eControlCode = rfCode}, deviceID)

return true

The ProntoCode and the Send a Broadlink IR or RF code worked with the device flashing orange when the command was sent.
The e-Control app did not seem do anything and I seem to recall reading somewhere that e-Control does not work with the RM4 Pro?

Sounds good. With the e-control app; you could get it to learn codes and then extract them for use with the plugin by finding them in the app file system. Maybe you can do the same with the app that runs RM4. It looks like you are good to go if you get some codes for your gear. So great effort so far.

Wanted to thank you guys so much for helping out on this painful journey which is not quite over but nearly there.

I could get IR learning through ALTUI devices to work although it took about 7 attempts to do.
RF which is key for me could not get to learn at all. So the orange light comes on in learning mode but just does not save anything.
Now I managed to record and save through the Broadlink app and it kinda works (it does not seem to record fully but it works). But there does not seem to be a way to get to the learnt codes.
Broadlink support have said that e-Control does not work with RM4. Is there another way to record and/or get the codes?

You can use the python-broadlink cli that you previously installed. For example:

# Learn and save to file
broadlink_cli --device @BEDROOM.device --learnfile LG-TV.power
# LEard and show at console
broadlink_cli --device @BEDROOM.device --learn 

Give that a try - it has worked great for me in the past.

Hi I have been trying to connect a rm2 pro to openLuup.
I have installed plugin
i have a child rm pro device and a temp device
the rm pro device has no variables
i have removed device from cloud and run broadlink cli.
the device is pingable from command line
Does any one have an idea where i have gone wrong
log

2020-07-11 15:50:22.571   openLuup.scheduler:: [25] BroadLink-Mk2 device startup
2020-07-11 15:50:22.571   luup_log:25: BroadLink_Mk2 debug: Initialising plugin: BroadLink_Mk2
2020-07-11 15:50:22.572   luup_log:25: BroadLink_Mk2 debug: Using: Lua 5.1
2020-07-11 15:50:22.572   luup_log:25: BroadLink_Mk2 debug: 0.55 --> PluginVersion
2020-07-11 15:50:22.572   luup_log:25: BroadLink_Mk2 debug: Using: dkjson
2020-07-11 15:50:22.573   luup_log:25: BroadLink_Mk2 debug: 300 --> PollInterval
2020-07-11 15:50:22.577   luup_log:25: BroadLink_Mk2 debug: Set socket name failed: permission denied
2020-07-11 15:50:22.578   luup_log:25: BroadLink_Mk2 debug: Header to be sent follows (ex checksum):

5A A5 AA 55 5A A5 AA 55  00 00 00 00 00 00 00 00   Z..UZ..U........
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
00 00 00 00 87 27 65 00  00 00 35 84 C7 34 EA 34   .....'e...5..4.4
00 00 00 00 76 C4 00 00   ....v...

2020-07-11 15:50:22.579   luup_log:25: BroadLink_Mk2 debug: Payload to be sent follows (unencrypted):

00 00 00 00 09 76 28 34  3F E9 9E 23 76 5C 15 13   .....v(4?..#v\..
AC CF 8B 02 00 00 00 00  00 00 00 00 00 00 00 00   ................
00 00 00 00 00 00 00 00  00 00 00 00 00 01 00 00   ................
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................

2020-07-11 15:50:22.612   luup_log:25: BroadLink_Mk2 debug: Sending:  Authorisation: txMsg length = 136
2020-07-11 15:50:22.612   luup_log:25: BroadLink_Mk2 debug: TX of Authorisation msg to 192.168.1.15 failed: refused
2020-07-11 15:50:22.613   luup_log:25: BroadLink_Mk2 debug: This device is probably offline - mac address: 34:ea:34:c7:84:35
2020-07-11 15:50:22.613   luup_log:25: BroadLink_Mk2 debug: k = rf433
2020-07-11 15:50:22.613   luup_log:25: BroadLink_Mk2 debug: k = rf433 has no associated code at this time
2020-07-11 15:50:22.614   luup_log:25: BroadLink_Mk2 debug: k = ir
2020-07-11 15:50:22.614   luup_log:25: BroadLink_Mk2 debug: 34:ea:34:c7:84:35_ir
2020-07-11 15:50:22.614   luup_log:25: BroadLink_Mk2 debug: 34:ea:34:c7:84:35
2020-07-11 15:50:22.615   luup_log:25: BroadLink_Mk2 debug: RM2 Pro Plus 2 - IR 1
2020-07-11 15:50:22.615   luup_log:25: BroadLink_Mk2 debug: urn:schemas-micasaverde-com:device:IrTransmitter:1
2020-07-11 15:50:22.616   luup_log:25: BroadLink_Mk2 debug: D_BroadLink_Mk2_IrRf_1.xml
2020-07-11 15:50:22.616   luup_log:25: BroadLink_Mk2 debug: type = function, value = function: 0xf250d28
2020-07-11 15:50:22.616   luup_log:25: BroadLink_Mk2 debug: k = rf315
2020-07-11 15:50:22.617   luup_log:25: BroadLink_Mk2 debug: k = rf315 has no associated code at this time
2020-07-11 15:50:22.617   luup_log:25: BroadLink_Mk2 debug: k = temp
2020-07-11 15:50:22.618   luup_log:25: BroadLink_Mk2 debug: 34:ea:34:c7:84:35_temp
2020-07-11 15:50:22.618   luup_log:25: BroadLink_Mk2 debug: 34:ea:34:c7:84:35
2020-07-11 15:50:22.618   luup_log:25: BroadLink_Mk2 debug: RM2 Pro Plus 2 - temperature 1
2020-07-11 15:50:22.619   luup_log:25: BroadLink_Mk2 debug: urn:schemas-micasaverde-com:device:TemperatureSensor:1
2020-07-11 15:50:22.619   luup_log:25: BroadLink_Mk2 debug: D_TemperatureSensor1.xml
2020-07-11 15:50:22.619   luup_log:25: BroadLink_Mk2 debug: type = function, value = function: 0xf425210
2020-07-11 15:50:22.620   luup_log:25: BroadLink_Mk2 debug: {"34:ea:34:c7:84:35":{"blInternalId":"????","blKey":"097628343fe99e23765c1513accf8b02","blDeviceType":10119,"blIp":"192.168.1.15","blDesc":"RM2 Pro Plus 2"}} --> BroadLinkDevices
2020-07-11 15:50:22.620   luup.chdev.append:: [34:ea:34:c7:84:35_ir] RM2 Pro Plus 2 - IR 1
2020-07-11 15:50:22.621   luup.chdev.append:: [34:ea:34:c7:84:35_temp] RM2 Pro Plus 2 - temperature 1
2020-07-11 15:50:22.621   luup.chdev.sync:: [25] BroadLink-Mk2, syncing children
2020-07-11 15:50:22.622   luup.set_failure:: status = false
2020-07-11 15:50:22.624   luup.variable_set:: 25.urn:micasaverde-com:serviceId:HaDevice1.CommFailure was: false now: false #hooks:0
2020-07-11 15:50:22.625   luup.variable_set:: 25.urn:micasaverde-com:serviceId:HaDevice1.CommFailureTime was: 1594482466 now: 1594482622 #hooks:0
2020-07-11 15:50:22.625   openLuup.scheduler:: [25] BroadLink-Mk2 device startup completed: status=true, msg=All OK, name=BroadLink_Mk2
2020-07-11 15:50:22.626   luup_log:3: ALTUI: UPNPregisterDataProvi

The authorisation message failed. What happens if your run the broadlink_discovery command that is included with the broadlink_cli? If broadlink_discovery discovers your devices, then the authorization is working, otherwise it isn’t and is most likely that the cloud lock bit is still enabled.

My bad, you even said you were using an rm2 but I missed that. The aforementioned doesn’t apply to the older broadlink devices.

That said, the plugin seems to be experiencing “permission denied” errors during tcp/ip sessions. Are you running openluup in docker by chance?

no, on a Debian virtual machine on Android.
Tried discovery runs but returns nothing.
The broadlink app sees my device but i have not given permission to add it to the app.

Then your device is not visible from your Debian VM on Android… I would check your networking…

You should see something like the following when discovery works:

╭─blacey@bbl ~/Projects/python-broadlink ‹unlock*› 
╰─$ ./cli/broadlink_discovery 
Discovering...
###########################################
RM2
# broadlink_cli --type 0x279d --host 192.168.0.122 --mac 780f77182387 --name 智能遥控 --cloud False
Device file data (to be used with --device @filename in broadlink_cli) : 
0x279d 192.168.0.122 780f77182387
temperature = 0.0

###########################################
RM2
# broadlink_cli --type 0x279d --host 192.168.0.123 --mac 780f771823c1 --name 智能遥控 --cloud False
Device file data (to be used with --device @filename in broadlink_cli) : 
0x279d 192.168.0.123 780f771823c1
temperature = 0.0

###########################################
RM2
# broadlink_cli --type 0x279d --host 192.168.0.120 --mac 780f771823bb --name 智能遥控 --cloud False
Device file data (to be used with --device @filename in broadlink_cli) : 
0x279d 192.168.0.120 780f771823bb
temperature = 0.0

###########################################
RM2
# broadlink_cli --type 0x2737 --host 192.168.0.121 --mac 780f771845fc --name 智能遥控 --cloud False
Device file data (to be used with --device @filename in broadlink_cli) : 
0x2737 192.168.0.121 780f771845fc
temperature = 0.0

###########################################
RM4
# broadlink_cli --type 0x51da --host 192.168.0.125 --mac 24dfa734ad2e --name 智能遥控 --cloud False
Device file data (to be used with --device @filename in broadlink_cli) : 
0x51da 192.168.0.125 24dfa734ad2e
temperature = 0.0

I just got
“discovering…”

Think this may be a root issue with ports below 1024.

Thing is, Debian is all new to me. Slowly getting my head around it.

I will read up on trying to run it as root see if that helps.

Works great for IR but still no joy with RF
IR
./broadlink_cli --type 0x6026 --host redacted --mac 24dfa7d32c05 --learn
Learning…
260c1c39371c1c1c1d…c1c1c391c1c1c1c381b1d391c1c000d05000000000000
Base64: JgBgABsdH…BwcOBwcHBw5HBwcHDgbHTkcHAANBQAAAAAAAA==

RF
./broadlink_cli --type 0x6026 --host redacted --mac 24dfa7d32c05 --learn
Learning…
No data received…

As I mentioned before it will learn RF with broadlink app

I don’t use RF but give it a shot with --rfscanlearn instead of --learn and see what happens.

╭─blacey@bbl ~/Projects/python-broadlink ‹unlock*› 
╰─$ ./cli/broadlink_cli --help                                                                                                                                                                                                                                                                       
usage: broadlink_cli [-h] [--device DEVICE] [--type TYPE] [--host HOST]
                     [--mac MAC] [--name NAME] [--temperature] [--energy]
                     [--check] [--checknl] [--turnon] [--turnoff] [--turnnlon]
                     [--turnnloff] [--switch] [--send] [--sensors] [--learn]
                     [--rfscanlearn] [--learnfile LEARNFILE] [--durations]
                     [--convert] [--joinwifi JOINWIFI JOINWIFI] [--unlock]
                     [--fwversion]
                     [data [data ...]]

positional arguments:
  data                  Data to send or convert

optional arguments:
  -h, --help            show this help message and exit
  --device DEVICE       device definition as 'type host mac'
  --type TYPE           type of device
  --host HOST           host address
  --mac MAC             mac address (hex reverse), as used by python-broadlink
                        library
  --name NAME           device name
  --temperature         request temperature from device
  --energy              request energy consumption from device
  --check               check current power state
  --checknl             check current nightlight state
  --turnon              turn on device
  --turnoff             turn off device
  --turnnlon            turn on nightlight on the device
  --turnnloff           turn off nightlight on the device
  --switch              switch state from on to off and off to on
  --send                send command
  --sensors             check all sensors
  --learn               learn command
  --rfscanlearn         rf scan learning
  --learnfile LEARNFILE
                        save learned command to a specified file
  --durations           use durations in micro seconds instead of the
                        Broadlink format
  --convert             convert input data to durations
  --joinwifi JOINWIFI JOINWIFI
                        Args are SSID PASSPHRASE to configure Broadlink device
                        with

still no luck

./broadlink_cli --type 0x6026 --host redacted --mac 052cd3a7df24 --rfscan

Learning RF Frequency, press and hold the button to learn…

RF Frequency not found

Why did you invert the mac address when trying to learn RF? Try this:

./broadlink_cli --type 0x6026 --host redacted --mac 24dfa7d32c05 --rfscanlearn

Typically, I copy and paste the command directly from the broadlink_discovery output.

I had read that you needed to invert the address but also discovery returns the address inverted
./broadlink_discovery
Discovering…
###########################################
RM4

broadlink_cli --type 0x6026 --host redacted --mac 052cd3a7df24

Device file data (to be used with --device @filename in broadlink_cli) :
0x6026 192.168.1.111 052cd3a7df24
temperature = 0.0

Tried the other way and same result

./broadlink_cli --type 0x6026 --host redacted --mac 24dfa7d32c05 --rfscan
Learning RF Frequency, press and hold the button to learn…
RF Frequency not found

We know that RF learning through the broadlink app works so I wonder if the learning protocol for RF has changed with version RM4?

I believe you are correct… I personally don’t have the time or hardware to extend the RF capabilities for the RM4 series of devices. If you read through the python-broadlink GitHub issue list, you might uncover what we need to change in the plugin. Once we know the extent of the changes, we can decide who gets to take a shot at developing and testing changes :wink:

You can use sudo ./broadlink_discovery to run it under root.

I will try but it is perilously close to my understanding of some of these things :slight_smile:

Still only getting
“discovering…”