Hass.io setup only read out all of my Xiaomi (Aqara) sensors when I restart my Hass.io (Pi3)

My hass.io setup only read out all of my Xiaomi (Aqara) sensors when I restart my Hass.io (Pi3).

When I try to turn on the light on the Gateway 2 see a error in the Developer section info

Error executing service <ServiceCall light.turn_on: entity_id=[‘light.gateway_light_7811dcb07501’]>
09:41 components/light/xiaomi_aqara.py (ERROR)
Got error element in data {“error”:“Invalid key”}
09:41 components/light/xiaomi_aqara.py (ERROR)

The key is correct because the system read out the sensors after a restart.

My setup:

xiaomi_aqara:
discovery_retry: 10
gateways:
- host: 192.168.x.xxx
mac: 7811dcxxxxxx
key: qs4feiiprxxxxxxx

Hass.io 0.61.1
Raspberry Pi 3
Xiaomi Gateway 2
Xiaomi Aqara Temp and Humidity sensor
Xiaomi Smart Home Aqara Human Body Sensor

How to fix this?

that format doesn’t seem right

I would think you should be using the one gateway format? That is how I have mine setup at least. Make sure the format of the yaml is right. I noticed a few things like yeelight won;t break the system if the file is wrong but it messes with the setup.

Thank you for the suggestion.
When I use that format in my current setup, Hass.io can’t discover the Gateway.

Used format:
xiaomi_aqara:
discovery_retry: 5
gateways:
- key: qs4feiiprxxxxxxx

I keep trying to solve this problem, tonight I try the next steps:

  • Setup another router
  • Factory reset Gatway
  • Reinstall Hass.io without any installed Add-ons
  • Only add the sugest xiaomi_aqara format to configcuration.yaml with a new generated key.

The key is only used for controlling lights, switches and the gw, so you will still see the states of the devices if the key is wrong.

Thanks for the clarification.
Without a key I don’t see any sensor.
I wil try first a new setup.

I have don the steps:

  • Setup another router
  • Factory reset Gateway
  • Reinstall Hass.io without any installed Add-ons
  • Only add the sugest xiaomi_aqara format to configcuration.yaml with a new generated key.

Result:
When I use te sugest xiaomi_aqara format in configcuration.yaml with a new generated key. My setup won’t discover the Gateway and don’t see the Xiaomi Aqara Temp and Humidity sensor and Xiaomi Smart Home Aqara Human Body Sensor.

But if I use the next format:

xiaomi_aqara:
discovery_retry: 10
gateways:
- host: 192.168.x.xxx
mac: 7811dcxxxxxx
key: xx1xxxxxxxxxxxxx

I see the gateway (light switch) and Xiaomi Aqara Temp and Humidity sensor and Xiaomi Smart Home Aqara Human Body Sensor. But hass.io don’t detect any motion. The system read out the sensors after a restart op Hass.io

When I try to turn on the light on the Gateway 2 see a error in the Developer section info:

Error executing service <ServiceCall light.turn_on: entity_id=['light.gateway_light_7811dcb07501']>
13:29 components/light/xiaomi_aqara.py (ERROR)
Got error element in data {"error":"Invalid key"}
13:29 components/light/xiaomi_aqara.py (ERROR)

Someone a suggestion?

I have setup a new network for the domotica setup and it is working now.