Xiaomi Philips Wifi Bulb Binding

Hi Marcel, thank for you response and big thanks on the development of the binding first of all.

So I have changed the item type to Dimmer, however I still can’t get the ON/OFF to work again now.

Here is a dump of the log file when I tried it out with log level set to debug.

This used to work before.

My items file is as follows

Switch Switch_LivingRoomLamp_OnOff "Lamp" <lightbulb> {channel="miio:basic:060C931A:power"}
Dimmer Dimmer_LivingRoomLamp_Brightness "Brightness" <lightbulb> {channel="miio:basic:060C931A:brightness"}

My Sitemap is as follows
sitemap lighting label=“Lighting” {

Frame label="Living Area Lamp"
{
    Switch item=Switch_LivingRoomLamp_OnOff label="Power"
    Setpoint item=Dimmer_LivingRoomLamp_Brightness maxValue=100 step=10 label="Brightness"
}

}

The Lamp Thing is configured from Paper UI

With regards to the device token, that is the one I got with the MIIO tool. When I created the think (with cloud credentials for Xiaomi) it got the same token so it should be good.

seems the log file went bit different than I expected.

log:set debug org.openhab.binding.miio
log:tail org.openhab.binding.miio

should produce the proper log (output from the binding with communication with the device)

https://pastebin.com/sCCic7fG

does that indicate an incorrect token ?

  1. 08:17:00.661 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 060C931A type: MIIO_INFO, result: {}, fullresponse: {“error”:“Given final block not properly padded. Such issues can arise if a bad key is used during decryption.”}

mah… what gives the hint :wink:

Hey it works, the token must have changed because I factory reset the bulb several times. I go the token using the old version of the mi home app and it’s fine now. Thanks a lot for your help.
Something that I noticed now it an exception when serializing the response from the bulb. number format exception. This is the stack trace in case there is an issue.

13:37:50.929 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Error while handing message {“result”:{“life”:160590,“token”:“ecbae18f773c861846edbf1c6b3c8488”,“mac”:“7C:49:EB:C6:CE:A8”,“fw_ver”:“1.3.7_0029”,“hw_ver”:“ESP8266”,“uid”:“6199171985”,“model”:“philips.light.hbulb”,“wifi_fw_ver”:“1.5.0-dev(7efd021)”,“ap”:{“rssi”:-66,“ssid”:“April”,“bssid”:“F8:08:4F:88:54:06”},“netif”:{“localIp”:“192.168.1.236”,“mask”:“255.255.255.0”,“gw”:“192.168.1.254”},“mmfree”:17600},“id”:8342}
com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: “6199171985”
at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:227) ~[bundleFile:?]
at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:217) ~[bundleFile:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) ~[bundleFile:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) ~[bundleFile:?]
at com.google.gson.Gson.fromJson(Gson.java:888) ~[bundleFile:?]
at com.google.gson.Gson.fromJson(Gson.java:953) ~[bundleFile:?]
at com.google.gson.Gson.fromJson(Gson.java:926) ~[bundleFile:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.updateProperties(MiIoAbstractHandler.java:358) ~[bundleFile:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.defineDeviceType(MiIoAbstractHandler.java:353) ~[bundleFile:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.onMessageReceived(MiIoAbstractHandler.java:462) [bundleFile:?]
at org.openhab.binding.miio.internal.handler.MiIoBasicHandler.onMessageReceived(MiIoBasicHandler.java:499) [bundleFile:?]
at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:236) [bundleFile:?]

token seems to change on every reset

Yes indeed, tokens are renewed on each reset/new pair to the mihome app.

Indeed that was unfortunately bug introduced for some of the uids (uid >. 2147483647) this has been fixed in the latest snapshot build of the binding.

Has anyone experienced the device ThingType to not get automatically changed upon provision of the token?
I am willing to add a Philips Zhirui E14 candle bulb, I am able to add it as a thing and provide the token, but still the binding reports it as miio:generic. Respectively the channels needed to manipulate the light are missing: only available is Execute Command
Nevertheless, the bulb does communicate with the binding as it is reported online and its id gets populated.
Maybe something missing in the database configuration?

Here the debug log. https://pastebin.com/tkDYstnP
It is the same number format exception as reported few posts above. The token certainly works as I see device online, and also able to communicate with it via python-miio

BTW, I also tried to define manually as miio:basic via things and items files, but this did not work.

Update: reading the comment of @marcel_verpaalen regarding bug for uid > 2147483647, I tried to installing newer snapshot. Originally I was running 2.5.4 and after some search managed to find jar with 2.5.4.202004171947. Installed and run it, but behavior is the same (and the NumberFormatException as in the log above thrown) … :roll_eyes:

snapshots should have version number of 2.5.5, all lower would be snapshots of 2.5.4 (so from before 2.5.4-release which you prob found).

You should be able to pull latest/greatest snapshot here
https://openhab.jfrog.io/openhab/libs-snapshot-local/org/openhab/addons/bundles/org.openhab.binding.miio/2.5.5-SNAPSHOT/
(you can mix 2.5.5-snapshot with 2.5.4 release)

Pls give some feedback on the channels for your model philips.light.candle as I have not seen feedback on that one yet.

The latest 2.5.5 (202005150359) worked out - the issue is not in place there.
Discovered channels 2.5.4 vs 2.5.5. Thanks for the link with the latest snapshots!

For the testing yet just linked Power, but will try all and provide update here.