Page 1 of 1

Error: XiaomiGateway: unable to write command - Invalid key

Posted: Friday 21 August 2020 19:11
by aray
Hi there.

I've recently created a simple web page where I call domoticz API to control my Xiaomi smart home. The domoticz server runs on a raspberry pi and the smart home configuration consists of xiaomi getaway, YeeLight bulbs and a couple of temperature sensors.

It has been working perfectly about two weeks, but then the connection to getaway became unstable. The Temp + Humidity + Baro sensor stopped to push its values and Toggle command starts randomly returning the "Error sending switch command". Besides, when there are no errors, the light sometimes does not turn on.

Here is the log:
Spoiler: show

Code: Select all

2020-08-21 04:58:48.662  Error: XiaomiGateway: unable to write command - Invalid key
2020-08-21 04:58:48.662  Status: XiaomiGateway: SendMessageToGateway failed on first attempt, will try again
2020-08-21 04:58:48.913  Error: XiaomiGateway: unable to write command - Invalid key
2020-08-21 04:58:57.475  Status: User: Admin initiated a switch command (13/Getaway light/Toggle)
2020-08-21 04:58:57.632  (Xiaomi Getway) Color Switch (Getaway light)
2020-08-21 04:59:04.438  Status: User: Admin initiated a switch command (13/Getaway light/Toggle)
2020-08-21 04:59:04.595  (Xiaomi Getway) Color Switch (Getaway light)
2020-08-21 04:59:26.556  Status: User: Admin initiated a switch command (13/Getaway light/Toggle)
2020-08-21 04:59:26.708  Error: XiaomiGateway: unable to write command - Invalid key
2020-08-21 04:59:26.708  Status: XiaomiGateway: SendMessageToGateway failed on first attempt, will try again
2020-08-21 04:59:26.959  Error: XiaomiGateway: unable to write command - Invalid key
2020-08-21 04:59:31.631  Status: User: Admin initiated a switch command (13/Getaway light/Toggle)
2020-08-21 04:59:31.788  (Xiaomi Getway) Color Switch (Getaway light)
2020-08-21 04:59:32.500  (Xiaomi Getway) Color Switch (Getaway light)
2020-08-21 04:59:33.114  (Xiaomi Getway) Color Switch (Getaway light)
2020-08-21 05:00:57.698  Status: User: Admin initiated a switch command (13/Getaway light/Toggle)
2020-08-21 05:00:57.849  Error: XiaomiGateway: unable to write command - Invalid key
2020-08-21 05:00:57.850  Status: XiaomiGateway: SendMessageToGateway failed on first attempt, will try again
2020-08-21 05:00:58.106  (Xiaomi Getway) Color Switch (Getaway light)
All devices and wifi router are in the same room.

Raspberry OS: 10 (buster)
Domoticz version: 2020.2

I would appropriate if someone can help me to localize the problem

Re: Error: XiaomiGateway: unable to write command - Invalid key

Posted: Friday 18 September 2020 12:07
by aray
The problem was solved by disabling power management on my raspberry:

Code: Select all

sudo iwconfig wlan0 power off