-
-
Notifications
You must be signed in to change notification settings - Fork 38.1k
Add HomematicIP alarm control panel #15342
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 6 commits into
home-assistant:dev
from
worm-ee:add-homematicip_cloud-alarm_panel
Jul 13, 2018
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bc216a2
Add HomematicIP security zone
worm-ee e4e5f39
Update access point tests
worm-ee 5590ccf
Fix state if not armed and coments
worm-ee 3f4aa7c
Add comment for the empty state_attributes
worm-ee 94cd382
Fix comment
worm-ee 87e73e6
Fix spelling
worm-ee 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
86 changes: 86 additions & 0 deletions
86
homeassistant/components/alarm_control_panel/homematicip_cloud.py
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,86 @@ | ||
| """ | ||
| Support for HomematicIP alarm control panel. | ||
|
|
||
| For more details about this component, please refer to the documentation at | ||
| https://home-assistant.io/components/alarm_control_panel.homematicip_cloud/ | ||
| """ | ||
|
|
||
| import logging | ||
|
|
||
| from homeassistant.const import ( | ||
| STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, | ||
| STATE_ALARM_TRIGGERED) | ||
| from homeassistant.components.alarm_control_panel import AlarmControlPanel | ||
| from homeassistant.components.homematicip_cloud import ( | ||
| HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN, | ||
| HMIPC_HAPID) | ||
|
|
||
|
|
||
| DEPENDENCIES = ['homematicip_cloud'] | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| HMIP_OPEN = 'OPEN' | ||
| HMIP_ZONE_AWAY = 'EXTERNAL' | ||
| HMIP_ZONE_HOME = 'INTERNAL' | ||
|
|
||
|
|
||
| async def async_setup_platform(hass, config, async_add_devices, | ||
| discovery_info=None): | ||
| """Set up the HomematicIP alarm control devices.""" | ||
| pass | ||
|
|
||
|
|
||
| async def async_setup_entry(hass, config_entry, async_add_devices): | ||
| """Set up the HomematicIP alarm control panel from a config entry.""" | ||
| from homematicip.aio.group import AsyncSecurityZoneGroup | ||
|
|
||
| home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home | ||
| devices = [] | ||
| for group in home.groups: | ||
| if isinstance(group, AsyncSecurityZoneGroup): | ||
| devices.append(HomematicipSecurityZone(home, group)) | ||
|
|
||
| if devices: | ||
| async_add_devices(devices) | ||
|
|
||
|
|
||
| class HomematicipSecurityZone(HomematicipGenericDevice, AlarmControlPanel): | ||
| """Representation of an HomematicIP security zone group.""" | ||
|
|
||
| def __init__(self, home, device): | ||
| """Initialize the security zone group.""" | ||
| device.modelType = 'Group-SecurityZone' | ||
| device.windowState = '' | ||
| super().__init__(home, device) | ||
|
|
||
| @property | ||
| def state(self): | ||
| """Return the state of the device.""" | ||
| if self._device.active: | ||
| if (self._device.sabotage or self._device.motionDetected or | ||
| self._device.windowState == HMIP_OPEN): | ||
| return STATE_ALARM_TRIGGERED | ||
|
|
||
| if self._device.label == HMIP_ZONE_HOME: | ||
| return STATE_ALARM_ARMED_HOME | ||
| return STATE_ALARM_ARMED_AWAY | ||
|
|
||
| return STATE_ALARM_DISARMED | ||
|
|
||
| async def async_alarm_disarm(self, code=None): | ||
| """Send disarm command.""" | ||
| await self._home.set_security_zones_activation(False, False) | ||
|
|
||
| async def async_alarm_arm_home(self, code=None): | ||
| """Send arm home command.""" | ||
| await self._home.set_security_zones_activation(True, False) | ||
|
|
||
| async def async_alarm_arm_away(self, code=None): | ||
| """Send arm away command.""" | ||
| await self._home.set_security_zones_activation(True, True) | ||
|
|
||
| @property | ||
| def device_state_attributes(self): | ||
| """Return the state attributes of the alarm control device.""" | ||
| return None | ||
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
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.
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.
Please add a code comment why we need to overwrite this property and return
None. This would look weird not knowing about the parent class implementation.