Xiaomi Gateway Integration

Have you enabled the API (dev mode) in the gateway via the xiaomi app?

Hi,

I tried making the mac lowercase, didn’t help/

Yes, the key and mac are both capitalised in the config.

I just have this in the config:

xiaomi:
  gateways:
   - mac: !secret x_gateway_mac
   - key: !secret x_gateway_key

From memory, when I added the above in the config a component got installed during HASS startup.

Yep, I have enabled the dev mode.

I too have the API enabled, and have rotated the keys a few times, about to go and give it another try with capitolisation…

Could you add these two lines
_LOGGER.error(gateway.sid)
_LOGGER.error(gw_sid)
here: https://github.com/home-assistant/home-assistant/blob/fada6d3f493ebf39732834a62bc86e281e3d6d6f/homeassistant/components/xiaomi.py#L114

And post the log?

It should work with colons and without. It should also work with capitalized letters

That means that the HA is not getting any response from your Xiaomi gateway.
Might be a local network problem or your firewall.
Try to leave the mac address blank.

Hm…can you recommend any debug steps for that?

Awaiting restart with blank mac…

Neither worked, currently fully capitolised the key, left MAC blank - how can I test if the network is the issue?

1 Like

I was using the wrong MAC :blush:

Changed the mac to the value printed in the log and it works now.
Thanks for your help :+1:

I can definately see a bunch of multicast traffic on my network, so there’s no general issue, looking at it it’s looking like the gateway might not be doing it (even though the screen in the app says it is :confused: )

Another update has appeared, will install and restart everything, see what happens…

Tried enabling and disabling local control in the app, didn’t help though

In the app, under network info I have current mode: remote connection - is that the same for you? do I need to restart the gateway after enabling local control?

Is now possible to use other server (like Singapore) and still use the gateway in HASS?

Hi,

Is it just me that the wall switches binary_sensor.wall_switch_* stopped working?
On the MiHome app they are there and creating an automation they work fine.
On HA I see the devices binary_sensor.wall_switch_* with the same name as the gateway app JSON response but debugging HA when I click on the wall switch it doesn’t even show. Any other stuff like illumination, binary_sensor.switch_*, etc shows fine on the debugger when I use them.

Thanks.

Edit: gateway version: 2.32 json version code: 140

Regards,

I’ve some issues with the two channel wall switch also. Xiaomi component have created 3 binary sensor (wall switch left, wall switch right, and both). But since a few days, I can’t trigger automation using the left one. Maybe an issue related to the recent firmware upgrade ?

1 Like

I have the same with a two channel wall switch, only works 1 of them…

Hi guys,
First of all, you have done a great job with Xiaomi Gateway.
Only recently I have got Xiaomi Smart Home set and started playing with it.
It is a great thing that most of sensors and options already working with HAAS.

One important feature is still missing, it is an ability to Arm or DisArm Alarm using HAAS.
I have done some research and found at page (https://www.gitbook.com/book/forrestfung/lumi-gateway-local-api/details) that there is API version 1.0.9 (https://cnbj2.fds.api.xiaomi.com/lumiaiot/common/gateway/绿米网关局域网通信协议V1.0.9_2017.08.01.doc).

It has the ability to simulate virtual click event over multicast with a command:
{“cmd”:“write”,“model”:“switch”,“sid”:“112316”,“short_id”:4343,“data”:"{“status”:“click”}" }

Perhaps we can make event function that would trigger this event on call, so HAAS could be configured to send Arm/DisArm (double click event).

2 Likes

There are also some nice features that could be useful for HAAS like API call for sub-device connection:
{“cmd”:“write”,“model”:“gateway”,“sid”:“6409802da2af”,“short_id”:0,“data”:"{“join_permission”:“yes”}" }

It’s possible to arm/disarm the gateway by the mi home app? I don’t think so.

Hey guys,

you have done an amazing job.
Since there are only components manageable, which are directly connected to the gateway, I cannot control my Xiaomi Wifi Remote Control Outlet Power Strip.
But my cube flip90 event turns the power strip on (Definition in the Xiaomi Home App).
And I can handle the event in HA.

Is the other way also possible?
I’d like to fire the same flip90 event from home assistant, so I can control the power strip indirectly through HA?

If so, could you please help me with some basic example?

Thanks.
Regards.

The power strip is supported by another component. Take a look here: Xiaomi mi wifi plug & air purifier - #122 by syssi

Next step will be a home assistant automation to connect both devices.