openhab / openhab-addons

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

[mihome] No token received from the gateway yet. Unable to encrypt the access key. #3577

Closed ninjax95 closed 3 years ago

ninjax95 commented 6 years ago

I’m trying to bind xiaomi home security hardware with openhab, I add the items. I can change the settings in the interface but nothing happens on the lamp. (as if the data was not sending itself)

Expected Behavior

I would like control my xiaomi gateway via openhab

Current Behavior

The lux goes well but the ignition control, for example, does not work.

Possible Solution

When I move the cursor ON/OFF of brightness :

2018-05-15 23:46:49.321 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler@40520dd1’: null
java.lang.NullPointerException: null
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:69) [202:org.openhab.binding.mihome:2.2.0]
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:42) [202:org.openhab.binding.mihome:2.2.0]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:291) [202:org.openhab.binding.mihome:2.2.0]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:277) [202:org.openhab.binding.mihome:2.2.0]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToBridge(XiaomiBridgeHandler.java:273) [202:org.openhab.binding.mihome:2.2.0]
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:188) [202:org.openhab.binding.mihome:2.2.0]
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:184) [202:org.openhab.binding.mihome:2.2.0]
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.execute(XiaomiActorGatewayHandler.java:73) [202:org.openhab.binding.mihome:2.2.0]
at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:104) [202: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.$Proxy137.handleCommand(Unknown Source) [202: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) [?:?]

Your Environment

VM with Ubuntu 16.04 java 8 I try with openhabian 1.4.1 openHAB2 installation from scratch only plugin binding-mihome - 2.2.0 application mi home on android phone : 5.1.33

wborn commented 6 years ago

Can you test this with 2.3.0-SNAPSHOT @ninjax95? This issue looks like a duplicate of https://github.com/openhab/openhab2-addons/issues/3384 which has already been fixed.

ninjax95 commented 6 years ago

Hi,

Thanks for reply, yes I can try 2.30-SNAPSHOT but do you a link and explain to install ? In Addons-->bindings there are only version 2.2.0

wborn commented 6 years ago

You'll need to update openHAB itself before you can test the newer version of the binding. How that is done depends on your platform and installation method. See also the documentation. There may be breaking changes when you update openHAB. So it's best to create a backup before you update to a newer version.

ninjax95 commented 6 years ago

Ok I reinstall from scratch install with openhab 2.30 SNAPSHOT.

Now I have this message in log when i change the curseur of brightness, color, etc... :

2018-05-22 00:26:23.300 [WARN ] [g.mihome.handler.XiaomiBridgeHandler] - No token received from the gateway yet. Unable to encrypt the access key.
2018-05-22 00:26:57.927 [WARN ] [g.mihome.handler.XiaomiBridgeHandler] - No token received from the gateway yet. Unable to encrypt the access key.
2018-05-22 00:26:58.563 [WARN ] [me.handler.XiaomiActorGatewayHandler] - Can't handle command 57 on channel mihome:gateway:7811dcb9e25a:color
2018-05-22 00:26:59.551 [WARN ] [g.mihome.handler.XiaomiBridgeHandler] - No token received from the gateway yet. Unable to encrypt the access key.

the dev code is well entered and correct

dimalo commented 6 years ago

hey @ninjax95, how is your network config? Openhab(Hardware:???) -> ??? -> Wifi -> Gateway

ghasemikasra39 commented 6 years ago

same issue. no solution ?

pulciux commented 5 years ago

Me too. I've tried 2.3, 2.4.M3, 2.4.M4 docker image amd64-debian and alpine. Always the same error:

2018-11-04 11:19:21.272 [WARN ] [g.mihome.handler.XiaomiBridgeHandler] - No token received from the gateway yet. Unable to encrypt the access key.
2018-11-04 11:19:21.274 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler@578e7cbc': null
java.lang.NullPointerException: null
    at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.toJsonValue(XiaomiBridgeHandler.java:323) [223:org.openhab.binding.mihome:2.4.0.M3]
acortesm commented 5 years ago

Same issue here. Any solution? 2018-11-25 09:05:10.780 [WARN ] [g.mihome.handler.XiaomiBridgeHandler] - No token received from the gateway yet. Unable to encrypt the access key.

dimalo commented 5 years ago

It’s important to know how the network is configured. Also for docker. I am running openhab 2.4.0 M6 on docker without any problems at the moment.

pulciux commented 5 years ago

Mine is: LAN on 192.168.0.x, there is a router acting as DHCP server and DNS server. The machine running Openhab (dockerized whit host LAN enabled) is connected by cable to the router through a Switch. A range extender is also connected by cable to the same switch. The range extender has a WiFi network enabled and the Xiaomi Gateway is connected by WiFi to the extender. There are also 2 Aqara IP camerea (with gateway capabilities) in the same network, but the development mode isn't enabled on those two cameras.

fwarmuth commented 5 years ago

Same problem, no solution?

igdr commented 5 years ago

Same problem, any updates?

JohnnyMa commented 4 years ago

Hi,

Thanks for bring us this awesome project! It really helps. Do we have ay progress on this item?

Thanks, Johnny

hmerk commented 3 years ago

closed due to inactivity