From ab6cb43d5b88eedf2f937652b15939625f024d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Sandstr=C3=B6m?= Date: Sun, 13 Sep 2015 07:42:38 +0200 Subject: [PATCH 1/6] alarm component --- homeassistant/components/alarm/__init__.py | 106 +++++++++++++++++ homeassistant/components/alarm/verisure.py | 110 ++++++++++++++++++ .../www_static/home-assistant-polymer | 2 +- homeassistant/components/sensor/verisure.py | 28 ----- homeassistant/components/verisure.py | 8 +- homeassistant/const.py | 7 ++ homeassistant/loader.py | 2 + 7 files changed, 231 insertions(+), 32 deletions(-) create mode 100644 homeassistant/components/alarm/__init__.py create mode 100644 homeassistant/components/alarm/verisure.py diff --git a/homeassistant/components/alarm/__init__.py b/homeassistant/components/alarm/__init__.py new file mode 100644 index 00000000000..449cbbbe452 --- /dev/null +++ b/homeassistant/components/alarm/__init__.py @@ -0,0 +1,106 @@ +""" +homeassistant.components.sensor +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Component to interface with various sensors that can be monitored. +""" +import logging +from homeassistant.helpers.entity import Entity +from homeassistant.helpers.entity_component import EntityComponent +from homeassistant.components import verisure +from homeassistant.const import ( + STATE_UNKNOWN, + STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY, + ATTR_ENTITY_PICTURE, + SERVICE_ALARM_DISARM, SERVICE_ALARM_ARM_HOME, SERVICE_ALARM_ARM_AWAY) + +DOMAIN = 'alarm' +DEPENDENCIES = [] +SCAN_INTERVAL = 30 + +ENTITY_ID_FORMAT = DOMAIN + '.{}' + +# Maps discovered services to their platforms +DISCOVERY_PLATFORMS = { + verisure.DISCOVER_SENSORS: 'verisure' +} + +SERVICE_TO_METHOD = { + SERVICE_ALARM_DISARM: 'alarm_disarm', + SERVICE_ALARM_ARM_HOME: 'alarm_arm_home', + SERVICE_ALARM_ARM_AWAY: 'alarm_arm_away', +} + +ATTR_CODE = 'code' + +ATTR_TO_PROPERTY = [ + ATTR_CODE, +] + +def setup(hass, config): + """ Track states and offer events for sensors. """ + component = EntityComponent( + logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL, + DISCOVERY_PLATFORMS) + + component.setup(config) + + def alarm_service_handler(service): + """ Maps services to methods on Alarm. """ + target_alarms = component.extract_from_service(service) + + if ATTR_CODE not in service.data: + return + + code = service.data[ATTR_CODE] + + method = SERVICE_TO_METHOD[service.service] + + for alarm in target_alarms: + getattr(alarm, method)(code) + + for service in SERVICE_TO_METHOD: + hass.services.register(DOMAIN, service, alarm_service_handler) + + return True + + +def alarm_disarm(hass, code, entity_id=None): + """ Send the alarm the command for disarm. """ + data = {ATTR_CODE: code} + + if entity_id: + data[ATTR_ENTITY_ID] = entity_id + + hass.services.call(DOMAIN, SERVICE_ALARM_DISARM, data) + + +def alarm_arm_home(hass, code, entity_id=None): + """ Send the alarm the command for arm home. """ + data = {ATTR_CODE: code} + + if entity_id: + data[ATTR_ENTITY_ID] = entity_id + + hass.services.call(DOMAIN, SERVICE_ALARM_ARM_HOME, data) + +def alarm_arm_away(hass, code, entity_id=None): + """ Send the alarm the command for arm away. """ + data = {ATTR_CODE: code} + + if entity_id: + data[ATTR_ENTITY_ID] = entity_id + + hass.services.call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data) + +class AlarmControl(Entity): + def alarm_disarm(self, code): + """ Send disar command. """ + raise NotImplementedError() + + def alarm_arm_home(self, code): + """ Send pause command. """ + raise NotImplementedError() + + def alarm_arm_away(self, code): + """ Send pause command. """ + raise NotImplementedError() diff --git a/homeassistant/components/alarm/verisure.py b/homeassistant/components/alarm/verisure.py new file mode 100644 index 00000000000..a8dbcec56f2 --- /dev/null +++ b/homeassistant/components/alarm/verisure.py @@ -0,0 +1,110 @@ +""" +homeassistant.components.alarm.verisure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Interfaces with Verisure alarm. +""" +import logging + +import homeassistant.components.verisure as verisure +import homeassistant.components.alarm as alarm + +from homeassistant.helpers.entity import Entity +<<<<<<< HEAD +from homeassistant.const import (STATE_UNKNOWN, + STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY) +======= +from homeassistant.const import STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY +>>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 + +_LOGGER = logging.getLogger(__name__) + + +def setup_platform(hass, config, add_devices, discovery_info=None): + """ Sets up the Verisure platform. """ + + if not verisure.MY_PAGES: + _LOGGER.error('A connection has not been made to Verisure mypages.') + return False + +<<<<<<< HEAD + alarms = [] + + alarms.extend([ +======= + sensors = [] + + sensors.extend([ +>>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 + VerisureAlarm(value) + for value in verisure.get_alarm_status().values() + if verisure.SHOW_ALARM + ]) + +<<<<<<< HEAD + add_devices(alarms) + + +class VerisureAlarm(alarm.AlarmControl): +======= + add_devices(sensors) + + +class VerisureAlarm(Entity): +>>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 + """ represents a Verisure alarm status within home assistant. """ + + def __init__(self, alarm_status): + self._id = alarm_status.id + self._device = verisure.MY_PAGES.DEVICE_ALARM +<<<<<<< HEAD + self._state = STATE_UNKNOWN +======= +>>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 + + @property + def name(self): + """ Returns the name of the device. """ + return 'Alarm {}'.format(self._id) + + @property + def state(self): + """ Returns the state of the device. """ + if verisure.STATUS[self._device][self._id].status == 'unarmed': +<<<<<<< HEAD + self._state = STATE_ALARM_DISARMED + elif verisure.STATUS[self._device][self._id].status == 'armedhome': + self._state = STATE_ALARM_ARMED_HOME + elif verisure.STATUS[self._device][self._id].status == 'armedaway': + self._state = STATE_ALARM_ARMED_AWAY + elif verisure.STATUS[self._device][self._id].status != 'pending': + _LOGGER.error('Unknown alarm state ' + verisure.STATUS[self._device][self._id].status) + return self._state +======= + return STATE_ALARM_DISARMED + if verisure.STATUS[self._device][self._id].status == 'armed_home': + return STATE_ALARM_ARMED_HOME + if verisure.STATUS[self._device][self._id].status == 'armed_away': + return STATE_ALARM_ARMED_AWAY +>>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 + + def update(self): + ''' update alarm status ''' + verisure.update() +<<<<<<< HEAD + + def alarm_disarm(self, code): + """ Send disarm command. """ + verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_DISARMED) + _LOGGER.warning('disarming') + + def alarm_arm_home(self, code): + """ Send arm home command. """ + verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_ARMED_HOME) + _LOGGER.warning('arming home') + + def alarm_arm_away(self, code): + """ Send arm away command. """ + verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_ARMED_AWAY) + _LOGGER.warning('arming away') +======= +>>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 diff --git a/homeassistant/components/frontend/www_static/home-assistant-polymer b/homeassistant/components/frontend/www_static/home-assistant-polymer index 1c82a536312..b0b12e20e0f 160000 --- a/homeassistant/components/frontend/www_static/home-assistant-polymer +++ b/homeassistant/components/frontend/www_static/home-assistant-polymer @@ -1 +1 @@ -Subproject commit 1c82a536312e8321716ab7d80a5d17045d20d77f +Subproject commit b0b12e20e0f61df849c414c2dfbcf9923f784631 diff --git a/homeassistant/components/sensor/verisure.py b/homeassistant/components/sensor/verisure.py index 61af1089775..47efa197870 100644 --- a/homeassistant/components/sensor/verisure.py +++ b/homeassistant/components/sensor/verisure.py @@ -36,12 +36,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None): hasattr(value, 'humidity') and value.humidity ]) - sensors.extend([ - VerisureAlarm(value) - for value in verisure.get_alarm_status().values() - if verisure.SHOW_ALARM - ]) - add_devices(sensors) @@ -103,25 +97,3 @@ class VerisureHygrometer(Entity): def update(self): ''' update sensor ''' verisure.update() - - -class VerisureAlarm(Entity): - """ represents a Verisure alarm status within home assistant. """ - - def __init__(self, alarm_status): - self._id = alarm_status.id - self._device = verisure.MY_PAGES.DEVICE_ALARM - - @property - def name(self): - """ Returns the name of the device. """ - return 'Alarm {}'.format(self._id) - - @property - def state(self): - """ Returns the state of the device. """ - return verisure.STATUS[self._device][self._id].label - - def update(self): - ''' update sensor ''' - verisure.update() diff --git a/homeassistant/components/verisure.py b/homeassistant/components/verisure.py index f084ce9874c..895a984cf86 100644 --- a/homeassistant/components/verisure.py +++ b/homeassistant/components/verisure.py @@ -58,8 +58,9 @@ from homeassistant.const import ( DOMAIN = "verisure" DISCOVER_SENSORS = 'verisure.sensors' DISCOVER_SWITCHES = 'verisure.switches' +DISCOVER_ALARMS = 'verisure.alarms' -DEPENDENCIES = [] +DEPENDENCIES = ['alarm'] REQUIREMENTS = [ 'https://github.com/persandstrom/python-verisure/archive/master.zip' ] @@ -121,7 +122,8 @@ def setup(hass, config): # Load components for the devices in the ISY controller that we support for comp_name, discovery in ((('sensor', DISCOVER_SENSORS), - ('switch', DISCOVER_SWITCHES))): + ('switch', DISCOVER_SWITCHES), + ('alarm', DISCOVER_ALARMS))): component = get_component(comp_name) _LOGGER.info(config[DOMAIN]) bootstrap.setup_component(hass, component.DOMAIN, config) @@ -164,7 +166,7 @@ def reconnect(): def update(): ''' Updates the status of verisure components ''' if WRONG_PASSWORD_GIVEN: - # Is there any way to inform user? + _LOGGER.error('Wrong password') return try: diff --git a/homeassistant/const.py b/homeassistant/const.py index 7d58dbb01d2..86c5a7ab6a5 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -43,6 +43,9 @@ STATE_CLOSED = 'closed' STATE_PLAYING = 'playing' STATE_PAUSED = 'paused' STATE_IDLE = 'idle' +STATE_ALARM_DISARMED = 'disarmed' +STATE_ALARM_ARMED_HOME = 'armed_home' +STATE_ALARM_ARMED_AWAY = 'armed_away' # #### STATE AND EVENT ATTRIBUTES #### # Contains current time for a TIME_CHANGED event @@ -110,6 +113,10 @@ SERVICE_MEDIA_NEXT_TRACK = "media_next_track" SERVICE_MEDIA_PREVIOUS_TRACK = "media_previous_track" SERVICE_MEDIA_SEEK = "media_seek" +SERVICE_ALARM_DISARM = "alarm_disarm" +SERVICE_ALARM_ARM_HOME = "alarm_arm_home" +SERVICE_ALARM_ARM_AWAY = "alarm_arm_away" + # #### API / REMOTE #### SERVER_PORT = 8123 diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 7b755214252..356d20c0620 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -123,6 +123,8 @@ def get_component(comp_name): # custom_components/switch/some_platform.py exists, # the import custom_components.switch would succeeed. if module.__spec__.origin == 'namespace': + + print("!!!!!!!!!!!!!!!!!!!!! " + module.__spec__.origin) continue _LOGGER.info("Loaded %s from %s", comp_name, path) From c9bccadc404518047ca6a626fde6a0f17f52c2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Sandstr=C3=B6m?= Date: Sun, 13 Sep 2015 07:48:34 +0200 Subject: [PATCH 2/6] fixed merge error --- homeassistant/components/alarm/verisure.py | 31 ---------------------- 1 file changed, 31 deletions(-) diff --git a/homeassistant/components/alarm/verisure.py b/homeassistant/components/alarm/verisure.py index a8dbcec56f2..1969273dfd1 100644 --- a/homeassistant/components/alarm/verisure.py +++ b/homeassistant/components/alarm/verisure.py @@ -9,12 +9,8 @@ import homeassistant.components.verisure as verisure import homeassistant.components.alarm as alarm from homeassistant.helpers.entity import Entity -<<<<<<< HEAD from homeassistant.const import (STATE_UNKNOWN, STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY) -======= -from homeassistant.const import STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY ->>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 _LOGGER = logging.getLogger(__name__) @@ -26,40 +22,24 @@ def setup_platform(hass, config, add_devices, discovery_info=None): _LOGGER.error('A connection has not been made to Verisure mypages.') return False -<<<<<<< HEAD alarms = [] alarms.extend([ -======= - sensors = [] - - sensors.extend([ ->>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 VerisureAlarm(value) for value in verisure.get_alarm_status().values() if verisure.SHOW_ALARM ]) -<<<<<<< HEAD add_devices(alarms) class VerisureAlarm(alarm.AlarmControl): -======= - add_devices(sensors) - - -class VerisureAlarm(Entity): ->>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 """ represents a Verisure alarm status within home assistant. """ def __init__(self, alarm_status): self._id = alarm_status.id self._device = verisure.MY_PAGES.DEVICE_ALARM -<<<<<<< HEAD self._state = STATE_UNKNOWN -======= ->>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 @property def name(self): @@ -70,7 +50,6 @@ class VerisureAlarm(Entity): def state(self): """ Returns the state of the device. """ if verisure.STATUS[self._device][self._id].status == 'unarmed': -<<<<<<< HEAD self._state = STATE_ALARM_DISARMED elif verisure.STATUS[self._device][self._id].status == 'armedhome': self._state = STATE_ALARM_ARMED_HOME @@ -79,18 +58,10 @@ class VerisureAlarm(Entity): elif verisure.STATUS[self._device][self._id].status != 'pending': _LOGGER.error('Unknown alarm state ' + verisure.STATUS[self._device][self._id].status) return self._state -======= - return STATE_ALARM_DISARMED - if verisure.STATUS[self._device][self._id].status == 'armed_home': - return STATE_ALARM_ARMED_HOME - if verisure.STATUS[self._device][self._id].status == 'armed_away': - return STATE_ALARM_ARMED_AWAY ->>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 def update(self): ''' update alarm status ''' verisure.update() -<<<<<<< HEAD def alarm_disarm(self, code): """ Send disarm command. """ @@ -106,5 +77,3 @@ class VerisureAlarm(Entity): """ Send arm away command. """ verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_ARMED_AWAY) _LOGGER.warning('arming away') -======= ->>>>>>> 614caa33ae4b9fd13bd26436dd4c1dd09ff01119 From 683a80f5f4a8fbd5de1278ea4b33077a54bb3b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Sandstr=C3=B6m?= Date: Sun, 13 Sep 2015 20:21:02 +0200 Subject: [PATCH 3/6] tests pass --- .../__init__.py | 30 ++++++------- .../verisure.py | 42 +++++++++++-------- .../www_static/home-assistant-polymer | 2 +- homeassistant/components/verisure.py | 4 +- homeassistant/loader.py | 2 - 5 files changed, 44 insertions(+), 36 deletions(-) rename homeassistant/components/{alarm => alarm_control_panel}/__init__.py (88%) rename homeassistant/components/{alarm => alarm_control_panel}/verisure.py (66%) diff --git a/homeassistant/components/alarm/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py similarity index 88% rename from homeassistant/components/alarm/__init__.py rename to homeassistant/components/alarm_control_panel/__init__.py index 449cbbbe452..f31be44e64f 100644 --- a/homeassistant/components/alarm/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -1,5 +1,5 @@ """ -homeassistant.components.sensor +homeassistant.components.alarm_control_panel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Component to interface with various sensors that can be monitored. """ @@ -8,12 +8,10 @@ from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_component import EntityComponent from homeassistant.components import verisure from homeassistant.const import ( - STATE_UNKNOWN, - STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY, - ATTR_ENTITY_PICTURE, + ATTR_ENTITY_ID, SERVICE_ALARM_DISARM, SERVICE_ALARM_ARM_HOME, SERVICE_ALARM_ARM_AWAY) -DOMAIN = 'alarm' +DOMAIN = 'alarm_control_panel' DEPENDENCIES = [] SCAN_INTERVAL = 30 @@ -30,12 +28,13 @@ SERVICE_TO_METHOD = { SERVICE_ALARM_ARM_AWAY: 'alarm_arm_away', } -ATTR_CODE = 'code' +ATTR_CODE = 'code' ATTR_TO_PROPERTY = [ ATTR_CODE, ] + def setup(hass, config): """ Track states and offer events for sensors. """ component = EntityComponent( @@ -43,15 +42,15 @@ def setup(hass, config): DISCOVERY_PLATFORMS) component.setup(config) - + def alarm_service_handler(service): """ Maps services to methods on Alarm. """ target_alarms = component.extract_from_service(service) - + if ATTR_CODE not in service.data: return - code = service.data[ATTR_CODE] + code = service.data[ATTR_CODE] method = SERVICE_TO_METHOD[service.service] @@ -72,7 +71,7 @@ def alarm_disarm(hass, code, entity_id=None): data[ATTR_ENTITY_ID] = entity_id hass.services.call(DOMAIN, SERVICE_ALARM_DISARM, data) - + def alarm_arm_home(hass, code, entity_id=None): """ Send the alarm the command for arm home. """ @@ -83,6 +82,7 @@ def alarm_arm_home(hass, code, entity_id=None): hass.services.call(DOMAIN, SERVICE_ALARM_ARM_HOME, data) + def alarm_arm_away(hass, code, entity_id=None): """ Send the alarm the command for arm away. """ data = {ATTR_CODE: code} @@ -92,15 +92,17 @@ def alarm_arm_away(hass, code, entity_id=None): hass.services.call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data) -class AlarmControl(Entity): + +class AlarmControlPanel(Entity): + """ ABC for alarm control devices. """ def alarm_disarm(self, code): - """ Send disar command. """ + """ Send disarm command. """ raise NotImplementedError() - + def alarm_arm_home(self, code): """ Send pause command. """ raise NotImplementedError() - + def alarm_arm_away(self, code): """ Send pause command. """ raise NotImplementedError() diff --git a/homeassistant/components/alarm/verisure.py b/homeassistant/components/alarm_control_panel/verisure.py similarity index 66% rename from homeassistant/components/alarm/verisure.py rename to homeassistant/components/alarm_control_panel/verisure.py index 1969273dfd1..52d5a21a8b4 100644 --- a/homeassistant/components/alarm/verisure.py +++ b/homeassistant/components/alarm_control_panel/verisure.py @@ -1,16 +1,16 @@ """ -homeassistant.components.alarm.verisure +homeassistant.components.alarm_control_panel.verisure ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Interfaces with Verisure alarm. +Interfaces with Verisure alarm control panel. """ import logging import homeassistant.components.verisure as verisure -import homeassistant.components.alarm as alarm +import homeassistant.components.alarm_control_panel as alarm -from homeassistant.helpers.entity import Entity -from homeassistant.const import (STATE_UNKNOWN, - STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY) +from homeassistant.const import ( + STATE_UNKNOWN, + STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY) _LOGGER = logging.getLogger(__name__) @@ -33,7 +33,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices(alarms) -class VerisureAlarm(alarm.AlarmControl): +class VerisureAlarm(alarm.AlarmControlPanel): """ represents a Verisure alarm status within home assistant. """ def __init__(self, alarm_status): @@ -56,24 +56,32 @@ class VerisureAlarm(alarm.AlarmControl): elif verisure.STATUS[self._device][self._id].status == 'armedaway': self._state = STATE_ALARM_ARMED_AWAY elif verisure.STATUS[self._device][self._id].status != 'pending': - _LOGGER.error('Unknown alarm state ' + verisure.STATUS[self._device][self._id].status) + _LOGGER.error( + 'Unknown alarm state %s', + verisure.STATUS[self._device][self._id].status) return self._state def update(self): ''' update alarm status ''' verisure.update() - + def alarm_disarm(self, code): """ Send disarm command. """ - verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_DISARMED) - _LOGGER.warning('disarming') - + verisure.MY_PAGES.set_alarm_status( + code, + verisure.MY_PAGES.ALARM_DISARMED) + _LOGGER.warning('disarming') + def alarm_arm_home(self, code): """ Send arm home command. """ - verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_ARMED_HOME) - _LOGGER.warning('arming home') - + verisure.MY_PAGES.set_alarm_status( + code, + verisure.MY_PAGES.ALARM_ARMED_HOME) + _LOGGER.warning('arming home') + def alarm_arm_away(self, code): """ Send arm away command. """ - verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_ARMED_AWAY) - _LOGGER.warning('arming away') + verisure.MY_PAGES.set_alarm_status( + code, + verisure.MY_PAGES.ALARM_ARMED_AWAY) + _LOGGER.warning('arming away') diff --git a/homeassistant/components/frontend/www_static/home-assistant-polymer b/homeassistant/components/frontend/www_static/home-assistant-polymer index b0b12e20e0f..1c82a536312 160000 --- a/homeassistant/components/frontend/www_static/home-assistant-polymer +++ b/homeassistant/components/frontend/www_static/home-assistant-polymer @@ -1 +1 @@ -Subproject commit b0b12e20e0f61df849c414c2dfbcf9923f784631 +Subproject commit 1c82a536312e8321716ab7d80a5d17045d20d77f diff --git a/homeassistant/components/verisure.py b/homeassistant/components/verisure.py index 895a984cf86..4e97cca0cd4 100644 --- a/homeassistant/components/verisure.py +++ b/homeassistant/components/verisure.py @@ -58,9 +58,9 @@ from homeassistant.const import ( DOMAIN = "verisure" DISCOVER_SENSORS = 'verisure.sensors' DISCOVER_SWITCHES = 'verisure.switches' -DISCOVER_ALARMS = 'verisure.alarms' +DISCOVER_ALARMS = 'verisure.alarms_control_panel' -DEPENDENCIES = ['alarm'] +DEPENDENCIES = ['alarm_control_panel'] REQUIREMENTS = [ 'https://github.com/persandstrom/python-verisure/archive/master.zip' ] diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 356d20c0620..7b755214252 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -123,8 +123,6 @@ def get_component(comp_name): # custom_components/switch/some_platform.py exists, # the import custom_components.switch would succeeed. if module.__spec__.origin == 'namespace': - - print("!!!!!!!!!!!!!!!!!!!!! " + module.__spec__.origin) continue _LOGGER.info("Loaded %s from %s", comp_name, path) From 6c3a78df30973ff3038fdda9c230c0af31bef7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Sandstr=C3=B6m?= Date: Sun, 13 Sep 2015 21:07:16 +0200 Subject: [PATCH 4/6] fixed spelling --- homeassistant/components/verisure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/verisure.py b/homeassistant/components/verisure.py index 5024efab6e6..3ae0ec9a7d9 100644 --- a/homeassistant/components/verisure.py +++ b/homeassistant/components/verisure.py @@ -59,7 +59,7 @@ from homeassistant.const import ( DOMAIN = "verisure" DISCOVER_SENSORS = 'verisure.sensors' DISCOVER_SWITCHES = 'verisure.switches' -DISCOVER_ALARMS = 'verisure.alarms_control_panel' +DISCOVER_ALARMS = 'verisure.alarm_control_panel' DEPENDENCIES = ['alarm_control_panel'] REQUIREMENTS = [ From 13ca42e18744fdb9151eafda38821f51f1faa952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Sandstr=C3=B6m?= Date: Mon, 14 Sep 2015 17:33:43 +0200 Subject: [PATCH 5/6] fixes from review --- .../components/alarm_control_panel/__init__.py | 6 +++--- .../components/alarm_control_panel/verisure.py | 11 ++++++----- homeassistant/components/verisure.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/alarm_control_panel/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py index f31be44e64f..bf68e35ffe3 100644 --- a/homeassistant/components/alarm_control_panel/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -1,7 +1,7 @@ """ homeassistant.components.alarm_control_panel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Component to interface with various sensors that can be monitored. +Component to interface with a alarm control panel. """ import logging from homeassistant.helpers.entity import Entity @@ -100,9 +100,9 @@ class AlarmControlPanel(Entity): raise NotImplementedError() def alarm_arm_home(self, code): - """ Send pause command. """ + """ Send arm home command. """ raise NotImplementedError() def alarm_arm_away(self, code): - """ Send pause command. """ + """ Send arm away command. """ raise NotImplementedError() diff --git a/homeassistant/components/alarm_control_panel/verisure.py b/homeassistant/components/alarm_control_panel/verisure.py index 52d5a21a8b4..a317428ffcd 100644 --- a/homeassistant/components/alarm_control_panel/verisure.py +++ b/homeassistant/components/alarm_control_panel/verisure.py @@ -49,6 +49,12 @@ class VerisureAlarm(alarm.AlarmControlPanel): @property def state(self): """ Returns the state of the device. """ + return self._state + + def update(self): + ''' update alarm status ''' + verisure.update() + if verisure.STATUS[self._device][self._id].status == 'unarmed': self._state = STATE_ALARM_DISARMED elif verisure.STATUS[self._device][self._id].status == 'armedhome': @@ -59,11 +65,6 @@ class VerisureAlarm(alarm.AlarmControlPanel): _LOGGER.error( 'Unknown alarm state %s', verisure.STATUS[self._device][self._id].status) - return self._state - - def update(self): - ''' update alarm status ''' - verisure.update() def alarm_disarm(self, code): """ Send disarm command. """ diff --git a/homeassistant/components/verisure.py b/homeassistant/components/verisure.py index 3ae0ec9a7d9..50fd9d6c7a9 100644 --- a/homeassistant/components/verisure.py +++ b/homeassistant/components/verisure.py @@ -125,7 +125,7 @@ def setup(hass, config): # Load components for the devices in the ISY controller that we support for comp_name, discovery in ((('sensor', DISCOVER_SENSORS), ('switch', DISCOVER_SWITCHES), - ('alarm', DISCOVER_ALARMS))): + ('alarm_control_panel', DISCOVER_ALARMS))): component = get_component(comp_name) _LOGGER.info(config[DOMAIN]) bootstrap.setup_component(hass, component.DOMAIN, config) From f5d1da1d53b9cd386fb51efd0810d6a58c1f46fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Sandstr=C3=B6m?= Date: Mon, 14 Sep 2015 19:42:36 +0200 Subject: [PATCH 6/6] and pylint... --- homeassistant/components/alarm_control_panel/verisure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/alarm_control_panel/verisure.py b/homeassistant/components/alarm_control_panel/verisure.py index a317428ffcd..f19cdc102d2 100644 --- a/homeassistant/components/alarm_control_panel/verisure.py +++ b/homeassistant/components/alarm_control_panel/verisure.py @@ -54,7 +54,7 @@ class VerisureAlarm(alarm.AlarmControlPanel): def update(self): ''' update alarm status ''' verisure.update() - + if verisure.STATUS[self._device][self._id].status == 'unarmed': self._state = STATE_ALARM_DISARMED elif verisure.STATUS[self._device][self._id].status == 'armedhome':