rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.64k stars 550 forks source link

could you pls add support to gateway's functions of security and light? #340

Closed xcray closed 6 years ago

xcray commented 6 years ago

As we know that the LAN API doesn't support controlling of the gw's security function (arming on/off, arming_wait_time) while miio interface does, so I think it's proper to use HA to control the security function, we need your help on python-miio codes. There is a plugin of homebridge, homebridge-mi-gateway-security for same function, maybe could been taken as reference. About the gateway's light, although HA can control it via the LAN API (xiaomi_aqara), but there is a problem that the official Mijia App will lost control of the light (the issue). Since miio interface can also interact with the light function of gw, I guess it could be a better choice.

Anyway, thanks very much for your cool repository!

syssi commented 6 years ago

You are very fast and clever. :-) I'm aware of the miIO arming methods (cp. #295) of the gateway and it will be part of python-miio some day. I don't want to integrate this feature into the xiaomi_aqara component of HA because of the mix of two libraries (protocols/APIs). Furthermore it would be hard to explain why two security tokens (the LAN protocol key and the miIO token) are required. I recommend to build an alarm automation at HA and try to avoid MiHome / Xiaomi Cloud automations.

rytilahti commented 6 years ago

I have a list of potential commands and a barebone support for the gatway, but the effort to add a proper support would be quite large (currently counting 73 available commands, no idea if and h ow all of them work..). If someone wants to work on it I may find some time to put it all into a somewhat readable state, however, as @syssi said, I would not be expecting this to get used by the HA at any point due to duplication of functionality and therefore it is not really a priority.

syssi commented 6 years ago

@xcray Take a look at my custom_component: https://github.com/syssi/xiaomi_raw/

It provides a switch platform (switch.xiaomi_raw_miio) which can be used to switch/toggle individual methods of the MiIO API. It should be possible to control the alarm and the light.

xcray commented 6 years ago

@syssi @rytilahti Thanks for your comments. Anyhow, it's my honor to having received your replies! Just for now, I don't think it's a good idea to completely get rid of official app and cloud. In my opinion, HA's capability to control the arming mode of xiaomi gateway is necessary, especially for the scene all of my family are out of home. I'll try your custom component on my host, so this issue could be closed. Thanks again for your cool codes!