-
-
Notifications
You must be signed in to change notification settings - Fork 37.6k
Point alarm control #20972
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
Merged
MartinHjelmare
merged 7 commits into
home-assistant:dev
from
fredrike:point-alarm_control
Feb 15, 2019
Merged
Point alarm control #20972
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2af8b93
initial working example of alarm_control
fredrike 75706b9
fixes for alarm_control
fredrike d28c346
arm home is the same as arm away
fredrike 576f765
updated documentation
fredrike 589a173
final fixes
fredrike ca84101
pypoint version up
fredrike b4b3c7d
fixes for Martin
fredrike File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| """Support for Minut Point.""" | ||
| import logging | ||
|
|
||
| from homeassistant.components.alarm_control_panel import (DOMAIN, | ||
| AlarmControlPanel) | ||
| from homeassistant.const import (STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED) | ||
| from homeassistant.components.point.const import ( | ||
| DOMAIN as POINT_DOMAIN, POINT_DISCOVERY_NEW) | ||
| from homeassistant.helpers.dispatcher import async_dispatcher_connect | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| async def async_setup_entry(hass, config_entry, async_add_entities): | ||
| """Set up a Point's alarm_control_panel based on a config entry.""" | ||
| async def async_discover_home(home_id): | ||
| """Discover and add a discovered home.""" | ||
| client = hass.data[POINT_DOMAIN][config_entry.entry_id] | ||
| async_add_entities([MinutPointAlarmControl(client, home_id)], True) | ||
|
|
||
| async_dispatcher_connect( | ||
| hass, POINT_DISCOVERY_NEW.format(DOMAIN, POINT_DOMAIN), | ||
| async_discover_home) | ||
|
|
||
|
|
||
| class MinutPointAlarmControl(AlarmControlPanel): | ||
| """The platform class required by Home Assistant.""" | ||
|
|
||
| def __init__(self, point_client, home_id): | ||
| """Initialize the entity.""" | ||
| self._client = point_client | ||
| self._home_id = home_id | ||
|
|
||
| @property | ||
| def _home(self): | ||
| """Return the home object.""" | ||
| return self._client.homes[self._home_id] | ||
|
|
||
| @property | ||
| def name(self): | ||
| """Return name of the device.""" | ||
| return self._home['name'] | ||
|
|
||
| @property | ||
| def state(self): | ||
| """Return state of the device.""" | ||
| return STATE_ALARM_DISARMED if self._home[ | ||
| 'alarm_status'] == 'off' else STATE_ALARM_ARMED_AWAY | ||
|
|
||
| def alarm_disarm(self, code=None): | ||
| """Send disarm command.""" | ||
| status = self._client.alarm_disarm(self._home_id) | ||
| if status: | ||
| self._home['alarm_status'] = 'off' | ||
|
|
||
| def alarm_arm_away(self, code=None): | ||
| """Send arm away command.""" | ||
| status = self._client.alarm_arm(self._home_id) | ||
| if status: | ||
| self._home['alarm_status'] = 'on' | ||
|
|
||
| @property | ||
| def unique_id(self): | ||
| """Return the unique id of the sensor.""" | ||
| return 'point.{}'.format(self._home_id) | ||
|
|
||
| @property | ||
| def device_info(self): | ||
| """Return a device description for device registry.""" | ||
| return { | ||
| 'identifiers': {(POINT_DOMAIN, self._home_id)}, | ||
| 'name': self.name, | ||
| 'manufacturer': 'Minut', | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.