Broadlink binding for RMx, A1, SPx and MP. Any interest?

Hello everyone,
Where should we insert the Auth Key and initial vector of the device? or we shouldn’t any more?
the binding recognize and add the thing rm2 pro through the UI

thank you for all the great work

Hi all,
I have the new binding workin with oh3.1
Auth key is automaticly detected, dont forget your *.map file.

see also a ir widget for oh3

thanks for the great work

Hi all,

I’ve an issue with the new OH3 broadlink binding. I’ve copied the file org.openhab.binding.broadlink-3.1.0-SNAPSHOT.jar to the addons direcotry and renamed it to org.openhab.binding.broadlink-3.1.0-SNAPSHOT-Beta-02.jar

bundle:list command in the cli shows that it’s correct loaded and active:


235 │ Active │ 80 │ 3.1.0.202101200419 │ openHAB Add-ons :: Bundles :: Broadlink Binding

The openhab.log file shows no serious error when loading the binding (only the warning, that no sitemap file is available, which I think, it’s ok - I’ve never used sitemaps):


2021-01-22 16:44:00.152 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘broadlink.sitemap’
2021-01-22 16:44:06.688 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘broadlink.sitemap’ is either empty or cannot be parsed correctly!
2021-01-22 16:44:11.022 [INFO ] [.discovery.BroadlinkDiscoveryService] - BroadlinkDiscoveryService - Constructed

But the binding is not visible in the Web configuration (menu: settings / binding):

It’s also not available in the list to add additional add-ons (it should be shown here in alphabetical order):

I’ve noticed in the openhab.log some additional log messages for an other binding (myq) which I’ve also copied manually to the addons directory. These additional message are not shown for the broadlink binding. Maybe this is a hint to the problem - but maybe it’s just because this myq binding is working and so it’s just visible as a thing in OH3 but the broadlink binding isn’t - but I’m not sure:


2021-01-22 16:44:00.116 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘myq.sitemap’
2021-01-22 16:44:06.688 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘myq.sitemap’ is either empty or cannot be parsed correctly!
2021-01-22 16:44:16.730 [INFO ] [openhab.event.ThingStatusInfoEvent ] - Thing ‘myq:account:2652ed125f’ updated: ONLINE
2021-01-22 16:44:16.731 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘myq:account:2652ed125f’ changed from UNKNOWN to ONLINE
2021-01-22 16:44:16.984 [INFO ] [openhab.event.ThingStatusInfoEvent ] - Thing ‘myq:garagedoor:2652ed125f:cg0850323341’ updated: ONLINE
2021-01-22 16:44:16.985 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘myq:garagedoor:2652ed125f:cg0850323341’ changed from UNKNOWN to ONLINE
2021-01-22 16:44:16.985 [INFO ] [openhab.event.ThingStatusInfoEvent ] - Thing ‘myq:garagedoor:2652ed125f:cg0850415355’ updated: ONLINE
2021-01-22 16:44:16.986 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘myq:garagedoor:2652ed125f:cg0850415355’ changed from UNKNOWN to ONLINE

All other bindings (which are included in OH3 and also manually copied to the addons directory are working without any problems).

My environment is an OH3 docker instance which I’ve created with the following command:

docker run \
–name openhab \
–net=host \
–tty \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-v /opt/OpenHAB-docker/conf:/openhab/conf \
-v /opt/OpenHAB-docker/userdata:/openhab/userdata \
-v /opt/OpenHAB-docker/addons:/openhab/addons \
-d \
–restart=always \
–env OPENHAB_HTTP_PORT=9080 \
–env OPENHAB_HTTPS_PORT=9443 \
–device=/dev/ttyACM0 \
openhab/openhab:3.0.0

Any idea about how to solve this problem would help. Thanks in advance and thanks for the great work to make this binding possible. Btw. I’ve used the broadlink binding in OH2.5 since a while and it’s works great.

Frank

In OH3 the binding does not show up in those lists.
Try to add a Thing and you will see it appearing in the options go choose from.
At least that was the case for me.

Hi Chris,
it was too simple that I couldn’t figure it out :wink:
Thanks a lot, it works now!

Okay so I’m horribly lost…I ‘think’ I understand how to get the two keys but Im confused on where Im supposed to enter this information. I created the device but have no options to enter this information in OH3 under the RM3 thing.

What am I not seeing/understanding?

Awesome stuff.

Can you ping me on here when you’ve written the Read me so I can review? When submitting to addon repo, don’t forget the POM and code owners files.

try new this addon for OH 3.0 but still no SP3s support. Anyone see an addon with working power consumption" ?

Hi @Cossey, I’ve had a first crack at the README - not much to it so would appreciate whatever you suggest.

@Zip_Zip I’d really like to be able to fix the power consumption issue with the SP3s - I’ve released a new Beta (Beta 3) which attempts to make it work by referring to the Python Broadlink library’s approach to reading the “energy” (sic) field. Unfortunately I don’t have a suitable device so I’ll have to rely on you (and any others with SP2, SP3s or MP2 devices) to tell me how it’s working.

Note that if you have an SP3s you’ll need to remove your existing Thing and rediscover it, as there’s now a whole new class of device which has the powerConsumption channel, while the old SP3 device does not. Your device should detect as a broadlink:sp3s Thing - if it doesn’t, well, that’s the first thing that I’ll need to fix :slight_smile:

Now the readme has some work; there are some more code changes that need to be done:

  • The channel types humidity, temperature and powerConsumption need to use the Unit of Measure system. This means that even if the temperature is fed into openhab in Celsius, the imperialists should get their reading in Fahrenheit. Same applies to the wattage, if I format it to kW in the pattern config it will automatically convert the value into kilowatt. That link above should explain what I mean.
  • In the /config/config.xml file, the parameters use the <required>true</required> tag which is depreciated, tag needs to be removed and use the attribute required on the param tag instead, example:
...
<parameter name="ipAddress" type="text" required="true">
...

I can try and put some time aside within the next week if you want me to look into it. Otherwise for the Unit of measure example, refer to other bindings - you can refer to what I did in the HP Printer binding for some guidance (it uses a different uom though)

bundles/org.openhab.binding.hpprinter folder

Look at the cumlMarkingUsed and inkLevel channel type and state pattern at /src/main/resources/OH-INF/thing/channel-types.xml.

Look at lines 678-687 in HPPrinterBinder.java (the channels that use the cumlMarkingUsed type. And lines 653-662 which use the inkLevel channel type (percentage value). You’ll notice the code which updates the channel and specifies what measurement unit the data is in.

If you go backwards and follow where the data comes from above for lines 678-687, you’ll eventually end up at line 109-127 in HPUsage.java which is where the binding gets the totalMarking data, and converts it into milli litres (the data itself can be in microlitres, millilitres or litres, there is the unit tag that tells us what the unit is coming from the printer so I use that to convert it to millilitres).

Hopefully this is a good example to start from. It might also be wise to check out a weather binding for some guidance for the temp and relative humidity, but idea should be the same. As long as you know what unit the numbers are in that you get from the device (which you’ve mentioned you do), you can feed that into openhab and tell it the unit so that it can convert it as needed. Just make sure you use the right <item-type> in the channel-types xml: Number:Dimensionless for percent, Number:Temperature for temp and Number:Power for the powerConsumption.

Hi guys,
may I step in with a question? I’m still on OH2 (2.5.11-1) and put the Beta-17 (broadlink-2.5.9.jar) in the addons folder. Everything is fine, the binding was added, my RM3 was discovered, but i can’t get the communication running, the thing configuration doesn’t have fields to enter the key and iv?



Any suggestions what to do?

Best regards jan

Fantastic advice - all suggestions implemented in Beta 4 now thanks @Cossey !

Also got steered in the correct direction re: power consumption calculations for supported devices - should be better now for SP2/SP3 and MP2 owners - please let me know how this looks if you have one of these devices in your OpenHAB 3.x system.

Hi Jan,
The key and IV fields were a constant source of problems for people getting started with the binding so I moved them to be preset with the correct secret values in 2.5 Beta 9 [Release Beta 9 - Encryption secrets now included · themillhousegroup/openhab2-addons · GitHub]; if you had an older beta running, something weird might have happened when you brought Beta 17 in over the top. You might need to totally remove everything Broadlink-related from your OpenHAB installation before trying Beta 17 again; e.g.:

  • remove all Broadlink-related Items
  • remove all Broadlink Things
  • remove the binding JAR

Sorry about the inconvenience, but that’s really the only way I can think of that you could get stuck like this, and the only way out of it. Best of luck!

It works perfectly with a RM pro plus. Many thanks for your great job. :clap: :clap: :clap:

Hi,
I have trouble installing the binding. I placed the .jar file in the addons folder, but it does not show up in PaperUI. According to the logs there is an unresolved requirement: Import-Package: org.openhab.core.config.core. This appears to be some core functionality, do I need to tweak anything?

Hi John,
thanks for the explanation. It was the very first time I tried to work with the Broadlink binding. I’ve removed the thing from PaperUI and then the binding from the addons folder. As the update to openhab 2.5.12-1 was waiting to be installed, I first updated the system, wait some time to get everything settled and started again.

The dicovery of my device was ok, I can see the authentication is set, but this ends with an Authentication failed. Then a java exception is thrown. This is repeating until I removed the thing again.
Is my device incompatible with the binding?

Model: RM mini 3
FCC Id: 2ACDZ-RMMINI3-RM

I live in Germany, the device was ordered a year ago from the Broadlink-Store on Amazon, but left in the bbox untouched. I had no time to start working with it until now. The setup of the WiFi net was done with " BroadLink -Universal TV Remote" on an Android phone, nothing more.

Is there anything else I can do to get closer to the error? I could set some kind of debug level, if advised how.

==> /var/log/openhab2/events.log <==
2021-01-31 17:50:33.997 [home.event.InboxAddedEvent] - Discovery Result with UID 'broadlink:rm3:24-df-a7-42-ee-ff' has been added.
2021-01-31 17:50:44.045 [me.event.InboxRemovedEvent] - Discovery Result with UID 'broadlink:rm3:24-df-a7-42-ee-ff' has been removed.
2021-01-31 17:50:44.096 [hingStatusInfoChangedEvent] - 'broadlink:rm3:24-df-a7-42-ee-ff' changed from UNINITIALIZED to INITIALIZING
2021-01-31 17:50:44.223 [hingStatusInfoChangedEvent] - 'broadlink:rm3:24-df-a7-42-ee-ff' changed from INITIALIZING to OFFLINE (COMMUNICATION_ERROR): Couldn't authenticate
==> /var/log/openhab2/openhab.log <==
2021-01-31 17:46:18.047 [INFO ] [.discovery.BroadlinkDiscoveryService] - BroadlinkDiscoveryService - Constructed
2021-01-31 17:50:33.870 [WARN ] [.discovery.BroadlinkDiscoveryService] - BroadlinkDiscoveryService - Beginning Broadlink device scan...
2021-01-31 17:50:33.880 [WARN ] [internal.discovery.DiscoveryProtocol] - Beginning async Broadlink device scan; will wait 10000 ms for responses
2021-01-31 17:50:33.913 [WARN ] [internal.discovery.DiscoveryProtocol] - Broadlink device scan waiting for 10000 ms to complete ...
2021-01-31 17:50:33.988 [INFO ] [.discovery.BroadlinkDiscoveryService] - Data received during Broadlink device discovery: from 192.168.38.242:80 [24:df:a7:42:ee:ff]
2021-01-31 17:50:33.996 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'broadlink:rm3:24-df-a7-42-ee-ff' to inbox.
2021-01-31 17:50:43.915 [WARN ] [internal.discovery.DiscoveryProtocol] - Device scan: wait complete ...
2021-01-31 17:50:43.917 [WARN ] [internal.discovery.DiscoveryProtocol] - Ended Broadlink device scan...
2021-01-31 17:50:43.921 [INFO ] [link.internal.socket.BroadlinkSocket] - Socket closed
2021-01-31 17:50:43.924 [INFO ] [.discovery.BroadlinkDiscoveryService] - Discovery complete. Found 1 Broadlink devices
2021-01-31 17:50:43.924 [INFO ] [link.internal.socket.BroadlinkSocket] - Receiver thread ended
2021-01-31 17:50:44.076 [INFO ] [dlink.handler.BroadlinkRemoteHandler] - rm3:24-df-a7-42-ee-ff[?]: constructed: resetting deviceKey to '097628343fe99e23765c1513accf8b02', length 32
2021-01-31 17:50:44.080 [INFO ] [dlink.handler.BroadlinkRemoteHandler] - rm3:24-df-a7-42-ee-ff[?]: (HINT: this should start '0976', end '8b02' and have length 32)
2021-01-31 17:50:44.189 [ERROR] [dlink.handler.BroadlinkRemoteHandler] - rm3:24-df-a7-42-ee-ff[?]: Authentication failed:
2021-01-31 17:50:44.191 [ERROR] [dlink.handler.BroadlinkRemoteHandler] - Broadlink Exception:
java.net.ProtocolException: Response from device is not valid. (0x22=0xFF,0x23=0xFF,0x24=0xFF)
        at org.openhab.binding.broadlink.internal.BroadlinkProtocol.decodePacket(BroadlinkProtocol.java:195) ~[bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.decodeDevicePacket(BroadlinkBaseThingHandler.java:180) ~[bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.authenticate(BroadlinkBaseThingHandler.java:140) [bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.transitionToOnline(BroadlinkBaseThingHandler.java:263) [bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.updateItemStatus(BroadlinkBaseThingHandler.java:216) [bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.initialize(BroadlinkBaseThingHandler.java:98) [bundleFile:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_152]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]
2021-01-31 17:50:44.217 [ERROR] [dlink.handler.BroadlinkRemoteHandler] - rm3:24-df-a7-42-ee-ff[?]: Attempting to authenticate prior to getting device status FAILED. Will mark as offline
2021-01-31 17:50:44.219 [WARN ] [dlink.handler.BroadlinkRemoteHandler] - rm3:24-df-a7-42-ee-ff[?]: Online -> Offline due to: Couldn't authenticate
2021-01-31 17:50:47.392 [ERROR] [dlink.handler.BroadlinkRemoteHandler] - rm3:24-df-a7-42-ee-ff[v]: Authentication failed:
2021-01-31 17:50:47.397 [ERROR] [dlink.handler.BroadlinkRemoteHandler] - Broadlink Exception:
java.net.ProtocolException: Response from device is not valid. (0x22=0xFF,0x23=0xFF,0x24=0xFF)
        at org.openhab.binding.broadlink.internal.BroadlinkProtocol.decodePacket(BroadlinkProtocol.java:195) ~[bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.decodeDevicePacket(BroadlinkBaseThingHandler.java:180) ~[bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.authenticate(BroadlinkBaseThingHandler.java:140) [bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.transitionToOnline(BroadlinkBaseThingHandler.java:263) [bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.updateItemStatus(BroadlinkBaseThingHandler.java:216) [bundleFile:?]
        at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler$1.run(BroadlinkBaseThingHandler.java:104) [bundleFile:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_152]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_152]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_152]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_152]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]

Jan

Hi, thx for your work!!!
i check sp3s on beta 4:

  • remove the old addon
  • remove all broadling stuff
  • add broadling new beta 4 addon
  • discover my broadlink sp3s and rm pro and add them again

but the power meter did not work(((( here is a screenshot http://prntscr.com/xxkmap It says null in the power consumption field, maybe I need to do something more? also light night mode not work http://prntscr.com/xxku3g

another glitch I noticed, that if I physically press the button on SP3s, openhub update status only after 30sec, (inside settings menu I set one second!!). for example official broadlink app IHC update status in 1-2 seconds. Is normal? or status update from openhub can’t be done faster, then 30 seconds?

Same here on latest OH3 SNAPSHOT:

2021-02-03 08:17:37.412 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.broadlink.jar

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.broadlink [22]

Unresolved requirement: Import-Package: org.openhab.core.config.core

at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]

at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]

at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]

at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]

at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]

at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

2021-02-03 08:18:10.768 [INFO ] [.discovery.BroadlinkDiscoveryService] - BroadlinkDiscoveryService - Constructed

Has anyone figured out the issue with the missing dependency?

Haven’t seen that issue I’m afraid @TilllScout - anyone else?

In other news I was able to obtain an SP2 and in setting it up found a possible issue when setting up a new device in OpenHAB 3 (as opposed to migrating an existing one from OH 2.x). That’s now fixed but the power consumption bytes I’m getting back are always zero. So I’m now wondering if the SP2 actually measures energy usage at all (I had a 24" screen plugged into it though a plug-in power meter that was recording 20-30W actual usage)

Here’s the Beta anyway:

@Zip_Zip you should be able to set it to 1sec polling with no ill effects - are you sure your configuration update saved?