Arm/disarm Xiaomi Gateway alarm

Hi. I am quite new with Home Assistant and I have some questions.I have just got a Xaiomi Gateway with some sensors. My HA can see all the sensors and I can control the gateway’s light, but I can’t find a way to arm/disarm the alarm from HA. Isn’t it possible? Also, I’ve noticed that the sensors are listed in the Entity Registry page, but not in the Integrations page (I tried to remove the gateway and sensors from HA to start from scratch, but how do I do this if it is not in the Integrations page?). My last question, I have an Aqara Zigbee bulb connected to the gateway, but it doesn’t show up in HA either. I guess it is not compatible? Thanks.

AFAIK, the alarm functionality is part of MI Home, and not the hub itself - either way, MI home automations are not exposed to HA.

Integrations page only shows ‘fully’ autodiscovered devices, in my case openuv and googlecast. The xiaomi kit isn’t included here.
If you want to delete xiaomi entities, use the entity register - select an entity, then select delete in bottom left of the popup - even though it says you need to go to integrations. Removing the hub from configuration.yaml should complete it I guess. (anyone?)

Currently, bulbs connected to the hub (zigbee) are not exposed via the xiaomi integration - only the gateway light itself.

1 Like

Thanks for your answer, walaj.

AFAIK, the alarm functionality is part of MI Home, and not the hub itself - either way, MI home automations are not exposed to HA…
…Currently, bulbs connected to the hub (zigbee) are not exposed via the xiaomi integration - only the gateway light itself.

Thats a pity, as I really wanted to use HA to arm/disarm the alarm. I set an Aqara Gateway in my parents house that I integrated with HA using the Homekit component, and HA recognises it as an alarm I can arm/disarm. Also, the Aqara zigbee bulb is discovered and I can control it. I assumed the Xiaomi gateway would work the same way, or even better as it has its own component (quite naive of me…). I don’t mind doing the alarm automation in “Mi Home” app, all I would like to do is arm/disarm it…is there a workaround to achieve that?

If you want to delete xiaomi entities, use the entity register - select an entity, then select delete in bottom left of the popup - even though it says you need to go to integrations. Removing the hub from configuration.yaml should complete it I guess.

You were right. I had already tried deleting the entities using the entity register, but they would show up again after restarting HA (even though I had removed the xiaomi_aqara component from configuration.yaml). The problem was the discovery component, which kept finding them. I removed discovery from configuration.yaml, just to check, and the sensors stopped showing up after restarting. Thanks!

HA has a couple of inbuilt and custom alarm components that can use the sensors from the gateway, you can then use the gateway to play one of the built in sound files or a custom one to be your alarm

This is possible. Try it. xiaomi_gateway_alarm

switch:
  - platform: xiaomi_gateway_alarm
    name: Xiaomi Gateway Alarm
    host: 192.168.1.x
    token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Gateway token
1 Like

It works flawlessly! That is exactly what I was looking for, thank you so much. Now, if I could find a way to control the Aqara zigbee bulb…that would make me so happy smile.png

oh cool (custom component)

Hello everyone!
@ hekm77 I saw your branch link as well as the “switch” code that you have so kindly provided but I am really not familiar with coding, so I would really appreciate your help in order to properly configure my HA to work with the aforementioned automation based on your custom component. What I have done so far is created a folder called “custom_components” under the config folder, then added another folder inside the “custom_components” one and called it “Xiaomi_Alarm” and then I downloaded the two files indicated inside your branch and put them inside the folder “Xiaomi_Alarm”. Afterwards, I have placed the code for the “switch” inside the configuration.yaml file of HA and restarted everything (I don’t think that the restart really took place). After all those steps I believe that there are a lot of things still missing, since my config doesn’t seem to be “Checked OK” upon inspection but also the HA doesn’t seem to be restarted after all. Also, there is nothing inside the “Overview” tab to indicate that there is a new switch with which I can interact. Please I would like from you as well as everyone else that can help, to instruct me step by step, if possible, on the steps and things that need configuring so that this custom component automation becomes functional. I am really sorry for the long post. Thank you in advance!

Hi @S1ou
Must be
111

Hi @hekm77
Thank you very much for your quick reply!
So if I just change the name of the folder from mine “Xiaomi_Alarm” to yours “xiaomi_gateway_alarm”, it should be working? Please note that the “switch.py” and “init.py” are indeed as you illustrate in the image. Is there anything else that needs to be done afterwards? Will I be able to see something new inside the “Overview” tab?

@S1ou
Yes, it works.
The folder should be named xiaomi_gateway_alarm
It contains files from github, switch.py and __init__.py
Add the code that is a few posts above in the configuration.yaml and specify the host and token of the Xiaomi Gateway.
After rebooting Home Assistant, you will have a new entity switch.xiaomi_gateway_alarm


Use this switch to arm / disarm.
Ringtone, volume, delay is set in MiHome app.
If you arm / disarm from the MiHome app, the switch status in the Home Assistant is updated after 10-15 seconds.

Not worked :frowning:
%D0%91%D0%B5%D0%B7%D1%8B%D0%BC%D1%8F%D0%BD%D0%BD%D1%8B%D0%B9

After update HA to 0.97.1 worked fine. Thanks @hekm77

1 Like

I’ve added a manifest.json and README

You are right! I messed up with the naming. You are quite right @hekm77
Thank you very much sir and sorry for the headache that I may have caused you!

I have just one last question.
Is it possible to arm two different xiaomi gateways either with the same switch or with a second one?
I am asking because I have installed in my home 2 gateways and 5 xiaomi alarm cameras. What I see is that when I arm the system, only the 1st gateway becomes armed and the rest of the interconnected cameras and gateway, stay disarmed, even though I have built a logic inside the Mi HOME app that when one gateway is armed, all other devices will automatically start arming. Should I create duplicate scripts for the second gateway or is there a faster way to arm/disarm everything?

Never mind! I found it! I have used the same logic for the second gateway.
The only problem now that I need to solve is how to integrate those two switches into one switch, and how to make the cameras arm & disarm as well.
Any tips here are highly welcome!

Hi @S1ou and @hekm77

I’m quite crazy trying to add arm/disarm switch, i added some screenshots with files created and after reviewing it 20 times, it doesn’t work. This is the message:

2019-11-17 00:43:38 ERROR (MainThread) [homeassistant.components.hassio] Platform error switch.xiaomi_gateway_alarm - Integration ‘xiaomi_gateway_alarm’ not found.

Hi @maximo80

token != key

Retrieving the Access Token

Thanks, You are right!!! I introduced gateway token and I works :smile:

Hi
Where can I find the “init.py” file? Its empty on github.

Yes, it’s an empty file. Download it.