Not able to get Xiaomi Gateway Key

Thank you mate, unfortunately it is not in HA - one thing I can think of based on your previous posts is that my port is not open - as my MAC is starting with your example…

Any workaround with maybe port forwarding instead of soldering?

nope…soldering only…

or buy a new one, a homekit compatible Aqara one!

2Olivier974

Hello!

I have aqara hub (zhwg11lm as I understand this means that this is v1 (is it so?)) And a great desire to bind it to HA. After researching the Internet on this topic, I lost hope (on this site, in the “// Xiaomi Gateway (Aqara)” section, the following is written: Unsupported Devices - Xiaomi Aqara Gateway (lumi.gateway.aqhm01), as it is not possible to activate dev mode in the Mi Home App.), but I found this thread. I read all your messages in which you write that you managed to connect exactly the zhwg11lm model.
I will describe my actions in detail:

  1. I registered my Aqara hub in the home WiFi network through the Aqara home application, in which I also updated the hub to the proposed firmware. The device has also been added to HomeKit.

  2. In configuration.yaml I add to the very beginning, with the FIRST line: dyscovery:
    save, reload HA.

3.1. I go to HA
3.2. I click the Settings tab, then the integrations, then I click + in the lower right corner, here I tried to add both Aqara hub and HomeKit Device.

Here, as I understood from your posts, a new device will be installed and a password request will appear, but nothing happens. What am I doing wrong?
Help please, I really don’t want to get the soldering iron.)

Hello! Can you help me with my post?

hello,

i use Mi Home App not “Aqara home”.

my Gateway is automaticaly discovered.

Your gateway need to be on the same network of your HomeAssistant server.
You have to be set to China mainland in the app and have a Chinese version, not a European one, or perhaps a Russian one? What is yours? Where did you bought it? what language is write on?

Now there is an integration in HA so you dont have to deal with yaml config anymore.
And i mean, the integrations for the Xiaomi gateway are automaticaly discovered.

Hope it help

Hi Olivier. Thanks for your help. i succefuly added my v3 mija gateway (automaticaly discovered and added - listed as Accessoire HomeKit - Mi Smart Home Hub-1791) to HomeAssistant. nevertheless i cannot see my mija Bluetooth température sensor in homeassistant (nothing is appearing). In MiHome app everything is working fine and i can see them and they are well connected to the gateway. What do i miss ?

Thanks for your help.

hello!

sorry i have any bluetooth sensor in my config…zigbee way is more simple,

sorry i cant help

Hi all, a small update for the
DGNWG05LM users (the one you get in EU when buying the Xiaomi Mi Sensor Set). I got lost in all the threads and it might be useful for those which have it.

You have to use the Xiaomi Miio integration.
You can recover the key using the “backup method”, ie install Xiomi app versiopn 5.0.19, see https://python-miio.readthedocs.io/en/latest/discovery.html#tokens-from-backups and extract the backup)?
To get the token, there is now an easier way ! pip3 install micloud && micloud. It will use the mi cloud to get your token, much easier!

Then you’ll have the gateway in HA and be able to arm the device, and disarm it. You can also control the color. There is no support for subdevices yet (all sensors) but it seems it’s coming, looking at https://github.com/rytilahti/python-miio/issues/728 there is significant progress.

4 Likes

wow… this actually worked great with the European version. Just the Alarm and light for now but better than nothing! I thought this was a lost cause. Thanks a lot!

I also have a DGNWG05LM EU getaway.
What I did was I’ve added https://github.com/AlexxIT/XiaomiGateway3 to HACS, so I could get the token in the most convenient way.
After that, I’ve added the Xiaomi Miio Integration manually, and it worked.

@vorion Strange that it worked with the DGNWG05LM EU, because the documentation says it shouldn’t work.
I never bothered with it then. Let’s try it.

I’ve only used the https://github.com/AlexxIT/XiaomiGateway3 repository to get the token. It logs in to the Xiaomi Cloud (as the Mi Home app) so you can get information (token, IP, MAC) for every device.
But you cannot add the gateway with that integration.

Well “works” is a matter of perspective. The DGNWG05LM will appear, you’ll be able to set the alarm and change the color but you won’t have access to any subdevices, neither be able to know if the alarm rings.

Hi Olivier

Thanks for your complete information here. I note you said that Aqara ZHWG11LM is OK and you have some? I have two, Both connect via the HomeKit integration in HA and I can turn the lights on and off so all is well there Port 9898 is not open so I am unable to use the sounds like the doorbell, which I would love to make go. I have tried connecting to a UART and while I can see the thing boot up etc. The commands psm-set network.open_pf 3 coming up with an error like not recognised command.

Did you manage to open the port on yours? if so how please?

Hello @bdb1,

yes i have 2 ZHWG11LM, the good news is you dont have to open Port 9898 or anything else!

You dont have the “ringtone” as an entity, you have to use it as a “service” : you need to read the doc :wink: :

https://www.home-assistant.io/integrations/xiaomi_aqara/

Services
The gateway provides the following services:

Service xiaomi_aqara.play_ringtone
Service xiaomi_aqara.stop_ringtone

example :

- alias: Let a dog bark on long press
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: long_click_press
  action:
    service: xiaomi_aqara.play_ringtone
    data:
      gw_mac: xxxxxxxxxxxx
      ringtone_id: 8
      ringtone_vol: 8

- alias: Stop barking immediately on single click
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: single
  action:
    service: xiaomi_aqara.stop_ringtone
    data:
      gw_mac: xxxxxxxxxxxx

enjoy!

The trigger can be whatever you want…a timer, a motion sensor, … you can even create an input.bolean to create a button to call the service.

If you want to have the “Alarm Panel” option, you need to use -> configuration -> integration -> + -> homekit accessories and add your Aqara Gateway, after that you can arm and disarm your gateway within Home Assistant.

Have fun!

Thanks so much for your reply. Sorry I should have said. I have two others that work fine that are a different model and the port is open. These ones when I run this in Developer mode (note the xx’s in the MAC are blanked for the forum:

Service: xiaomi_aqara.play_ringtone

Service Data:

gw_mac: ‘xx:xx:xx:xx:xx:xx’
ringtone_id: 10
ringtone_vol: 10

When I hit call service a black line comes upo down the bottom and says: (note the xxxxx in the MAC is blanked for this forum). Failed to call service xiaomi_aqara/play_ringtone. Unknown gateway sid xxxxxxxxx for dictionary value @ data[‘gw_mac’]

From Log

Logger: homeassistant.components.websocket_api.http.connection
Source: core.py:1405
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 8:57:55 (3 occurrences)
Last logged: 8:58:06

[140704683660624] Unknown gateway sid xxxxxxxxx for dictionary value @ data[‘gw_mac’]

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 135, in handle_call_service await hass.services.async_call( File “/usr/src/homeassistant/homeassistant/core.py”, line 1405, in async_call processed_data = handler.schema(service_data) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 272, in call return self._compiled([], data) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict return base_validate(path, iteritems(data), out) File “/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py”, line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: Unknown gateway sid xxxxxxx for dictionary value @ data[‘gw_mac’]

Hi Olivier

You seem to be the only person that has this working! So I am sorry to come back at you!! Can you please help?

I have tried and tried again with this but I still get the error. I simply want to play a sound. See the automation I have copied yours. The Gateway is in the Homekit Integration and I can turn the light on/off no problem but when I call the service in an automation or use the Developer tools I get the same error. Unknown gateway sid xxxxxxxxx for dictionary value @ data[‘gw_mac

Note the xx is there to obscure the MAC for the forum.

Thanks in advance

hi!

not well formated : its a syntax problem, try :

gw_mac: 54ef44ccxxxx
ringtone_id: 10
ringtone_vol: 10

enjoy!

Hi Olivier

Sorry. No dice. Copied your format and get:

Error executing script. Invalid data for call_service at pos 1: Unknown gateway sid 54ef44xzxxxxx for dictionary value @ data[‘gw_mac’]

hi

Are you sure its the right gateway mac adress?

go in MiHome APP and be sure of the IP first. Then go to download https://www.advanced-ip-scanner.com and chek your ip and copy your mac adress and compare…just to be sure…