tests pass
parent
c9bccadc40
commit
683a80f5f4
|
@ -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()
|
|
@ -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')
|
|
@ -1 +1 @@
|
|||
Subproject commit b0b12e20e0f61df849c414c2dfbcf9923f784631
|
||||
Subproject commit 1c82a536312e8321716ab7d80a5d17045d20d77f
|
|
@ -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'
|
||||
]
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue