openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.56k forks source link

[MiHome] Duplicate Gateway and Bridge things with leading zero ID #7507

Closed Terr4 closed 3 years ago

Terr4 commented 4 years ago

Expected Behavior

Adding a Xiaomi Bridge with a leading zero ID should only display one Bridge entry and one Gateway entry in OpenHAB

Current Behavior

I have a Xiaomi Bridge with Serial ID "04cf8c8f9bcd" (MAC address 04:cf:8c:8f:9b:cd). This ID has a leading zero. OpenHAB discovers two entries for the Bridge and the Gateway: mihome:bridge:04cf8c8f9bcd mihome:bridge:4cf8c8f9bcd mihome:gateway:04cf8c8f9bcd mihome:gateway:4cf8c8f9bcd

Bildschirmfoto 2020-04-30 um 18 27 35 Bildschirmfoto 2020-04-30 um 18 12 26

Possible Solution

don't trim the leading zero or use a character prefix

Steps to Reproduce (for Bugs)

  1. Have a Xiaomi Bridge with a leading zero mac address
  2. Install Xiaomi Binding
  3. Go to the Inbox Page in PaperUI
  4. See duplicate bridge and gateway entries

Context

I can delete the duplicate entries later in the things page or ignore it in PaperUI, it seems it has no negative impact except creating duplicate things and channels

Your Environment

lolodomo commented 4 years ago

Please enable DEBUG logs for the binding and then ask for new discovery. Finally show your logs to us.

anordvall commented 3 years ago

Hi! I have the exact same problem, but it do cause some issues for me. I raised a new issue report before I found this one, so please see https://github.com/openhab/openhab-addons/issues/8365 for description & DEBUG log. Hope you can help! :-)

anordvall commented 3 years ago

@lolodomo, I was going to test this so I downloaded org.openhab.binding.mihome-2.5.10-SNAPSHOT.jar from https://ci.openhab.org/view/Integration%20Builds%20(2.5.x)/job/openHAB2.5.x-Addons/lastSuccessfulBuild/ the 4th of October. Should I expect this fix/workaround to be in that build? If not, can you please point me in the right direction?

lolodomo commented 3 years ago

Considering the date of the merge, I believe the fix is simply in the official 2.5.9 release.

anordvall commented 3 years ago

@lolodomo, would you mind pointing me in the right direction for downloading this mihome 2.5.9 addon containing the workaround? I've tried to find it but I'm just about to give up. Any help would be very much appreciated :)

lolodomo commented 3 years ago

Just install/upgrade OH to 2.5.9 or 2.5.10 and you will get the fix.

The jar from the last snapshot build is also available here https://ci.openhab.org/job/openHAB2.5.x-Addons/ws/bundles/org.openhab.binding.mihome/target/org.openhab.binding.mihome-2.5.11-SNAPSHOT.jar

anordvall commented 3 years ago

Thanks for your quick response @lolodomo . I stayed on openHAB 2.5.7 (don't want to upgrade unless necessary), but downloaded the 2.5.11 snapshot from your URL. I deleted the mihome GW and re-added it. Now it has the gateway ID twice in the thing ID and each channel, which looks very weird. And it doesn't seem to work to e.g. change the GW brightness & color using it.

Any idea? :)

image

image

anordvall commented 3 years ago

@lolodomo now I removed both the mihome GW (had to click "Force remove") and the mihome bridge, restarted openHAB and Scanned for new mihome devices through Paper UI. Attaching a log containing "Start scan for bridges". Please have a look and see if it looks OK or not. Setting GW brightness and color still doesn't work :(

mihome.bug7507.log

anordvall commented 3 years ago

It seems I can't set the color & brightness on my other MiHome GW either anymore, so maybe it's a completely separate issue(?) and maybe the weird looking ID is still fine?

UPDATE: I guess this is the problem: No key set in the gateway settings. Edit it in the configuration. I'm sure I lost the gateway key when I upgraded to 2.5.7, so now I have to find out how I get it back but that's another question.. :)

UPDATE #2: I can confirm that the missing key was the reason for GW brightness/color didn't work. All fine for now :) Thanks!

Terr4 commented 3 years ago

Now it has the gateway ID twice in the thing ID

I think there was a change introduced at some point doing this. I use 2.5.9 and all new things I add through the binding have the gateway ID in the channel string as prefix, all things I added way before do not have the gateway string in the channel name but just the device id.

e.g. my temperature sensor had the ID "mihome:sensor_weather_v1:158d00025d8b50" but after re-adding it in 2.5.9 the channel string is now "mihome:sensor_weather_v1:7c49eb88b4e7:158d00025d8b50"

lolodomo commented 3 years ago

This is something that was probably fixed (not by myself).