miio icon indicating copy to clipboard operation
miio copied to clipboard

Toggle Alarm of Xiaomi gateway

Open micheleivani opened this issue 6 years ago • 15 comments

Hi, I'm trying the library for making a custom project with my Xiaomi devices. I have a Xiaomi Gateway and I'd like to toggle on and off the Alarm of Xiaomi Gateway. Any suggestion about it? I can build the functionality by myself but some tips will help me a lot.

Thank you

micheleivani avatar Sep 26 '17 09:09 micheleivani

Hi! This sounds like a great feature to add. To start it would help if you could create a Wireshark-capture and look at the commands that the Mi Home apps send. The documentation under Protocol and commands should help with getting you started.

aholstenson avatar Nov 04 '17 17:11 aholstenson

This might help (extract from my node-red plugin, I'm switching from these manually handled gateways to miio, but also need sound playback):

  • command to play sound on the gateway: https://github.com/pierrecle/node-red-contrib-mi-devices/blob/master/node-red-contrib-xiaomi-actions/xiaomi-actions.js#L103
  • sounds ids: https://github.com/pierrecle/node-red-contrib-mi-devices/blob/master/node-red-contrib-xiaomi-actions/xiaomi-actions.html#L283
  • stop and custom sounds: https://github.com/pierrecle/node-red-contrib-mi-devices/blob/master/node-red-contrib-xiaomi-actions/xiaomi-actions.html#L322

bemble avatar Jan 25 '18 00:01 bemble

@pierrecle Thanks for the links! Support for alarm sounds are coming, I looked into it just before I saw your links. Just need to figure out the best way to map it. Will probably get around to it this weekend or in the beginning of next week.

aholstenson avatar Jan 25 '18 20:01 aholstenson

@aholstenson

It seems this did not make it into the 0.15.x rebuild. Is this still on your roadmap? And would it be possible to also add functionality to switch the light on/off (cap:power) and change it's color (cap:colorable) and brightness (cap:dimmable).

jghaanstra avatar Mar 14 '18 19:03 jghaanstra

@jghaanstra It is, short on time for everything right now though so can't give any estimates on when it'll be done.

But, the functionality of the gateway light is exposed as subdevice of the gateway today, with full support for the power, brightness and colors. I think you can access it via gateway.child('light') if you want to get it from the gateway, otherwise by default it and the sensors connected to the gateway are made available as devices using miio.devices().

aholstenson avatar Mar 15 '18 08:03 aholstenson

Right, never thought of looking at the child devices for this functionality. Seems to be exactly what I was looking for. No worries about any estimates for the alarm, it's done when it's done. I know how it goes.

jghaanstra avatar Mar 15 '18 19:03 jghaanstra

FYI Query the status: {"id":65005,"method":"get_arming","params":[]} {"result":["off"],"id":65005}

Query the wait time: {"id":65006,"method":"get_arm_wait_time","params":[]} {"result":[5],"id":65006}

set arming: {"id":65013,"method":"set_arming","params":["on"]} {"result":["ok"],"id":65013}

set arming off: {"id":65014,"method":"set_arming","params":["off"]} {"result":["ok"],"id":65014}

xcray avatar Jun 15 '18 00:06 xcray

Thank you @xcray 👍 That's only for enable and disable the build in "alarm system", isn't it? Any way to trigger an alarm without a Xiaomi sensor? I for example only have hue sensors.

Head avatar Sep 22 '18 13:09 Head

Thanx for the commands. Toggling the alarm state is not that hard to add to the miio library but to do this properly the abstract things library which is used by the miio library needs to be expanded with a alarm capability. This is beyond my skills.

It seems @aholstenson does not have time to maintain this library anymore though.

jghaanstra avatar Oct 06 '18 12:10 jghaanstra

You can use this CLI command to enable or disable alarm :

miio protocol call <id> set_arming '["on"]' miio protocol call <id> set_arming '["off"]'

yobrx avatar Oct 08 '18 20:10 yobrx

I tried but is still block without answer

C:>miio protocol call 87635042 set_arming '["off"]' INFO Attempting to call set_arming on 87635042 INFO Device found, making call

and then nothing. Any idea?

alazzari74 avatar Jan 05 '19 22:01 alazzari74

Hi,

Thanks for this good lib 👍

Question regarding security features. Can we have a way to get the status of the alarm like gateway has trigger alarm.

For eg, I want to run a script if the alarm is triggered by some sensors to send to me SMS of Pushbullet notifications.

Thanks

floviolleau avatar Jan 28 '19 15:01 floviolleau

Hi, there is a homebridge plugin support this: https://github.com/YinHangCode/homebridge-mi-gateway-security It would be nice to support the feature in miio though, even better if miio can send notification when the alarm is triggered :)

maisun avatar Feb 06 '19 08:02 maisun

Any chance the alarm ringtone and doorbell sound will be supported in the near future? FYI Domoticz has these features implemented: https://github.com/domoticz/domoticz/blob/development/hardware/XiaomiGateway.cpp Maybe something to look into? Thanks!

xylone avatar May 22 '19 06:05 xylone

Hi,

I started to develop the alarm feature but I failed to add the different tests and stuff to get a successfull merge request.

https://github.com/toribola/home-assistant/blob/dev/homeassistant/components/xiaomi_aqara.py https://github.com/toribola/home-assistant/blob/dev/homeassistant/components/alarm_control_panel/xiaomi_gateway.py

Hope that it will be added in a near future !

Regards,

toribola avatar Oct 31 '19 16:10 toribola