-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xiaomi aqara gateway alarm control #20294
Xiaomi aqara gateway alarm control #20294
Conversation
📚Please, update the documentation and open a PR for it (be sure to create a documentation PR against the 🏷 I am adding the 👍 Thanks (times a million!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preliminary review, in order to get this merged the protocol-specific parts need to be moved into the upstream lib (see rytilahti/python-miio#470) and all references to xiaomi_aqara need to be removed.
from homeassistant.components.alarm_control_panel import AlarmControlPanel | ||
import homeassistant.helpers.config_validation as cv | ||
from homeassistant.components.switch import (PLATFORM_SCHEMA, ) | ||
from homeassistant.components.xiaomi_aqara import (CONF_HOST, CONF_TOKEN, ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import CONF_HOST and CONF_TOKEN from homeassistant.const instead of from xiaomi_aqara.
_LOGGER = logging.getLogger(__name__) | ||
|
||
DEFAULT_NAME = 'Xiaomi Gateway Alarm' | ||
DATA_KEY = 'alarm_control_panel.xiaomi_gateway' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alarm_control_panel.xiaomi_miio
.
vol.Required(CONF_HOST): cv.string, | ||
vol.Required(CONF_TOKEN): vol.All(cv.string, vol.Length(min=32, max=32)), | ||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, | ||
vol.Optional(CONF_TURN_ON_COMMAND, default='set_arming'): cv.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some specific reason to make this and turn_off configurable?
vol.All(cv.ensure_list, [cv.string]), | ||
}) | ||
|
||
REQUIREMENTS = ['python-miio>=0.3.7'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be pinned on exact version, i.e. ==0.3.7
.
"""Turn on.""" | ||
result = await self._try_command( | ||
"Turning the miio device on failed.", self._device.send, | ||
'set_arming', ['on']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be implemented in the backend lib, I just pushed my old code online if you are interested in working on it: rytilahti/python-miio#470
"""Turn off.""" | ||
result = await self._try_command( | ||
"Turning the miio device off failed.", self._device.send, | ||
'set_arming', ['off']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this needs to be done in the upstream library.
|
||
print(result) | ||
if result: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug prints, do proper error handling if necessary.
'set_arming', ['off']) | ||
print(result) | ||
if result: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
try: | ||
state = await self.hass.async_add_job( | ||
self._device.send, 'get_arming', [self._state_property]) | ||
state = state.pop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be done in the upstream library.
@@ -285,6 +287,9 @@ def push_data(self, data, raw_data): | |||
_LOGGER.debug("PUSH >> %s: %s", self, data) | |||
was_unavailable = self._async_track_unavailable() | |||
is_data = self.parse_data(data, raw_data) | |||
print("=========================================================") | |||
print(raw_data) | |||
print("=========================================================") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all modifications and references to xiaomi_aqara. xiaomi_aqara implements the developer api access, xiaomi_miio is the correct one for this.
This PR seems to have gone stale. Closing it. |
Description:
Arm/Disarm xiaomi aqara alarm
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: