I have a problem with openhab2 communicating with the Mi home gateway. Discovering went fine, all devices are online but no sensor updates and command to devices (socket plug/gateway light) fail (after a restart of openhab discoverd things remain in “uninitialized”).
Similair issues are described here, solution in putting openhab and gateway in the same VLAN, disabling firewalls, adjusting vpn’s do not apply/solve to my situation.
Background info:
I use openhab2 on a pi3 with several sensors. I had everything working using the wifi network of my modem, pi and Mi-gateway. When using the pi’s wired connection (eth0) I did not get any sensor updates which might be caused by blocking multicasts between the wifi-network and the wired network on my modem (cannot change this). Since I want the Pi to connect to the modem via a wired connection I decided to configure the wlan0 interface of the pi to be a hotspot for the Mi-gateway to connect on. I configured ‘hostap’ running a dhcp server on the pi’s wlan interface creating a hotspot.
After resetting the Mi-gateway to use the pi’s hotspot I was able to add the Mi bridge & gateway (by hand using the paper ui) and discover all sensors. Unfortunately I do not get any sensor updates and cannot send any commands to my aqara devices (gateway light and socket-plug for exmaple). I tried to figure out if there is any communation required besides connecting on the Mi-gateways port 9898, found something about multicast but it is not clear to me if this is causing my issues and how to solve them.
My setup:
modem <–192.168.x.x–> etho pi3 wlan0 <–10.0.0.x–> Mi gateway (10.0.0.12)
Communicatin looks fine, I can use the pi’s hotspot with any device and access the internet and openhab’s nginx on the pi
All my sensors, gateway and bridge are online in the paperui (things will be uninitialized after a restart f openhab, a re-discovery will bring them online)
I am running openhab2, latest snapshot:
185 │ Active │ 90 │ 2.2.0.201712110910 │ openHAB Core
201 │ Active │ 80 │ 2.2.0.201712110910 │ Xiaomi Mi Smart Home Binding
Mi-Gateway software: 1.4.1_151.0143
pi: # iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
pi: # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.178.1 0.0.0.0 UG 0 0 0 eth0
default 192.168.178.1 0.0.0.0 UG 202 0 0 eth0
10.0.0.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.178.0 * 255.255.255.0 U 0 0 0 eth0
192.168.178.0 * 255.255.255.0 U 202 0 0 eth0
Adding multicast (?) to pi’s iptables does not seem to help:
iptables -A INPUT -i wlan0 -m pkttype --pkt-type multicast -j ACCEPT
pi: ~# nmap -sU -p 9898 10.0.0.12
Starting Nmap 6.47 ( http://nmap.org ) at 2017-12-11 23:05 CET
Nmap scan report for 10.0.0.12
Host is up (0.0049s latency).
PORT STATE SERVICE
9898/udp open unknown
MAC Address: 28:6C:07:F0:AF:F6 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 0.91 seconds
Trying to turn-on my zigbee socket plug (simalair error when turning on/off the gateway light):
[DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Device 158d00010319cc on channel mihome:sensor_plug:286c07f0aff6:158d00010319cc:power received command ON
[ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mihome.handler.XiaomiActorPlugHandler@19a7240': null
java.lang.NullPointerException: null
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:69) [201:org.openhab.binding.mihome:2.2.0.201712110910]
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:42) [201:org.openhab.binding.mihome:2.2.0.201712110910]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:291) [201:org.openhab.binding.mihome:2.2.0.201712110910]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:277) [201:org.openhab.binding.mihome:2.2.0.201712110910]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToDevice(XiaomiBridgeHandler.java:268) [201:org.openhab.binding.mihome:2.2.0.201712110910]
at org.openhab.binding.mihome.handler.XiaomiActorPlugHandler.execute(XiaomiActorPlugHandler.java:47) [201:org.openhab.binding.mihome:2.2.0.201712110910]
at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:104) [201:org.openhab.binding.mihome:2.2.0.201712110910]
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.201712111157]
at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [109:org.eclipse.smarthome.core:0.10.0.201712111157]
at com.sun.proxy.$Proxy137.handleCommand(Unknown Source) [201:org.openhab.binding.mihome:2.2.0.201712110910]
at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:72) [116:org.eclipse.smarthome.core.thing:0.10.0.201712111157]
at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [116:org.eclipse.smarthome.core.thing:0.10.0.201712111157]
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.201712111157]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [109:org.eclipse.smarthome.core:0.10.0.201712111157]
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) [?:?]
Looking for a solution for this setup, is multicast likely to be causing this communication problem, is there a way to test the required multicast communication? any halp would be appriciated.