Xiaomi Gateway Binding - no update of values


(Axel Thomas) #1

Hi guys,

I just started with using OH so please forgive any easy questions, it’s pretty hard to find the right information in all those huge threads with 100+ posts which cover multiple years and therefore the total development of the software.

At first, MY SETUP

  • Xiaomi Smart home works perfectli with the Mi Home App (Switches, Plugs, Light, Sensors)
  • OH2.2 on Win10
  • latest Zulu jdk x64 Java 8 (I think is was version 8u152)
  • Xiaomi Binding installed according to https://docs.openhab.org/addons/bindings/mihome/readme.html
  • Gateway was not auto discovered --> set to developer mode and added via things-file --> all sensors/switches got auto discovered

I thought that would be it and I could start adding my hardware an write some cool rules :sunglasses: … but my first test was to add the items for one power socket and try to control this manually via paperUI

as you can see in the log-file, on start-up the correct values of the power socket are read (power “on”, in-use “on”, power consumption “71,83 W”) and those match the values in the Xiaomi Mi Home App.

But those values are never updated in the paperui (do i have to do this manually with a rule?), for instance when I reduce the needed power or I switch of the plug via Mi Home App (is it possible, that Mi Home and OH have access to the Hardware at the same time?)

Additionally, I cannot switch the plug from the paperUI and the log of OH shows an error which i don’t understand, could you please give me a direction where to search for the reason?

Launching the openHAB runtime...

                          __  _____    ____
  ____  ____  ___  ____  / / / /   |  / __ )
 / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  |
/ /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/
    /_/                        2.2.0
                               Release Build

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown openHAB.

openhab> log:tail
21:51:21.594 [INFO ] [der.internal.HomeBuilderDashboardTile] - Started Home Builder at /homebuilder
21:51:22.467 [WARN ] [rg.eclipse.smarthome.core.net.NetUtil] - Found multiple local interfaces - ignoring 192.168.131.1
21:51:22.514 [WARN ] [rg.eclipse.smarthome.core.net.NetUtil] - Found multiple local interfaces - ignoring 192.168.178.21
21:51:22.993 [WARN ] [rg.eclipse.smarthome.core.net.NetUtil] - Found multiple local interfaces - ignoring 192.168.131.1
21:51:22.993 [WARN ] [rg.eclipse.smarthome.core.net.NetUtil] - Found multiple local interfaces - ignoring 192.168.178.21
21:51:23.150 [INFO ] [i.dashboard.internal.DashboardService] - Started dashboard at http://192.168.52.1:8080
21:51:23.150 [INFO ] [i.dashboard.internal.DashboardService] - Started dashboard at https://192.168.52.1:8443
21:51:28.460 [INFO ] [rthome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
21:51:29.018 [INFO ] [del.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'default.things', using it anyway:
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
21:51:29.018 [INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'default.things'
21:51:29.111 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'XiaomiMiSmartSocketPlugTV_PowerConsumed-mihome:sensor_plug:158d00010xxxxx:powerConsumed' has been added.
21:51:29.111 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'XiaomiMiSmartSocketPlugTV_Power-mihome:sensor_plug:158d00010xxxxx:power' has been added.
21:51:29.127 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'XiaomiMiSmartSocketPlugTV_InUse-mihome:sensor_plug:158d00010xxxxx:inUse' has been added.
21:51:29.127 [INFO ] [thome.event.ItemChannelLinkAddedEvent] - Link 'XiaomiMiSmartSocketPlugTV_ProvidedPower-mihome:sensor_plug:158d00010xxxxx:loadPower' has been added.
21:51:30.303 [INFO ] [.basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
21:51:30.350 [INFO ] [marthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
21:51:30.381 [INFO ] [bpanel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
21:51:30.725 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mihome:sensor_plug:158d00010xxxxxx' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
21:51:30.975 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mihome:bridge:286c078xxxxx' changed from UNINITIALIZED to INITIALIZING
21:51:31.006 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mihome:gateway:286c078xxxxx' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
21:51:32.096 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mihome:bridge:286c078xxxxx' changed from INITIALIZING to ONLINE
21:51:32.128 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mihome:sensor_plug:158d00010xxxxx' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
21:51:32.128 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mihome:gateway:286c078xxxxx' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
21:51:32.190 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mihome:gateway:286c078xxxxx' changed from INITIALIZING to ONLINE
21:51:32.190 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'mihome:sensor_plug:158d00010xxxxx' changed from INITIALIZING to ONLINE
21:51:32.206 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiSmartSocketPlugTV_Power changed from NULL to ON
21:51:32.221 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiSmartSocketPlugTV_InUse changed from NULL to ON
21:51:32.221 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiSmartSocketPlugTV_ProvidedPower changed from NULL to 71.83
21:51:32.221 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiSmartSocketPlugTV_PowerConsumed changed from NULL to 26.657
21:52:05.743 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'XiaomiMiSmartSocketPlugTV_Power' received command OFF
21:52:05.747 [INFO ] [smarthome.event.ItemStateChangedEvent] - XiaomiMiSmartSocketPlugTV_Power changed from ON to OFF
21:52:05.783 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mihome.handler.XiaomiActorPlugHandler@18fcc16f': null
java.lang.NullPointerException: null
        at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:69) [203:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:42) [203:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:291) [203:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:277) [203:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToDevice(XiaomiBridgeHandler.java:268) [203:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiActorPlugHandler.execute(XiaomiActorPlugHandler.java:47) [203:org.openhab.binding.mihome:2.2.0]
        at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:104) [203:org.openhab.binding.mihome:2.2.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at com.sun.proxy.$Proxy138.handleCommand(Unknown Source) [203:org.openhab.binding.mihome:2.2.0]
        at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:72) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
        at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]

Thanks in advance,
Axel


Xiaomi Robot Vacuum Binding
(Kuba Wolanin) #2

Could you submit a ticket? cc: @dimalo
Also, make sure your setup is compliant with docs.openhab.org/addons/bindings/mihome/readme.html
I wish I could help more, but I have no clue.
Cheers


(Axel Thomas) #3

Hello Kuba,

thanks for the extremely quick response.
I will try to submit a ticket. Maybe you can help me with my really basic questions, whether the paperUI should be auto-updated when the values change or not?


(SiHui) #4

Regarding those messages in your log, maybe the Xiaomi gateway is not connected to your main router?
Double check if you can see a wifi connection from your Xiaomi with a valid IP in your router setup.


(Axel Thomas) #5

if that would be the case, how could the first values could have been read on start of OH?

last time I checked, the Gateway (it is the one with light and radio) got a normal IP in the same subnet as my OH-Server (aka my Win10 notebook), but i will check again when i’m back home


(rb) #6

I had exactly the same issues. Gateway autodiscovery doesn’t work. If added manually its shown online and assigned sensors are discovered including the initial states.
But there is never an update, and newly paired sensors are also not discovered.

First, set the loglevel to debug for Xiaomi.
Then check the logs. There should be datagram getting in every ten seconds from each gateway. If not, there is something wrong with the UDP handling.

In my case the gateways were conected to an access point hosted by the Raspberry Pi. It required a change in the routing table, but this is a workaround. The binding needs a fix I think.

See this post for details:


And the following one for the workaround .


(Aaron Khare) #7

Hey, did you end up getting this to work for yourself?

I recently ran into the same issue after it was semi-stable and working on and off.

Turns out setting up a firewall rule to allow incoming connections on port 9898 (from this post) solved it for me. Now the heartbeat from the bridge/gateway appears under DEBUG and TRACE logs for the binding, PaperUI updates when changes are made via Google Home and I can control things with much more stability. Hope this helps in your instance :+1:


(Gonzalo Echevarria) #8

I had the same issue, my Rpi act as AP on wlan0 and eth0 is connected to main router to provide internet.
The Raspberry function very well and provide DHCP to all my devices (sonoff, cameras, etc).

The problem is that the xiaomi GW not discovered.

my network:
wlan: 172.27.1.0/24 gw 172.27.1.1
eth0: 192.168.1.0/24 gq 192.168.1.1 (adls router)

I tested with other raspberry connected to the same wlan and discover work perfect.