mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
tests pass
This commit is contained in:
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.
|
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.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.components import verisure
|
from homeassistant.components import verisure
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_UNKNOWN,
|
ATTR_ENTITY_ID,
|
||||||
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)
|
SERVICE_ALARM_DISARM, SERVICE_ALARM_ARM_HOME, SERVICE_ALARM_ARM_AWAY)
|
||||||
|
|
||||||
DOMAIN = 'alarm'
|
DOMAIN = 'alarm_control_panel'
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
SCAN_INTERVAL = 30
|
SCAN_INTERVAL = 30
|
||||||
|
|
||||||
@ -30,12 +28,13 @@ SERVICE_TO_METHOD = {
|
|||||||
SERVICE_ALARM_ARM_AWAY: 'alarm_arm_away',
|
SERVICE_ALARM_ARM_AWAY: 'alarm_arm_away',
|
||||||
}
|
}
|
||||||
|
|
||||||
ATTR_CODE = 'code'
|
ATTR_CODE = 'code'
|
||||||
|
|
||||||
ATTR_TO_PROPERTY = [
|
ATTR_TO_PROPERTY = [
|
||||||
ATTR_CODE,
|
ATTR_CODE,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Track states and offer events for sensors. """
|
""" Track states and offer events for sensors. """
|
||||||
component = EntityComponent(
|
component = EntityComponent(
|
||||||
@ -43,15 +42,15 @@ def setup(hass, config):
|
|||||||
DISCOVERY_PLATFORMS)
|
DISCOVERY_PLATFORMS)
|
||||||
|
|
||||||
component.setup(config)
|
component.setup(config)
|
||||||
|
|
||||||
def alarm_service_handler(service):
|
def alarm_service_handler(service):
|
||||||
""" Maps services to methods on Alarm. """
|
""" Maps services to methods on Alarm. """
|
||||||
target_alarms = component.extract_from_service(service)
|
target_alarms = component.extract_from_service(service)
|
||||||
|
|
||||||
if ATTR_CODE not in service.data:
|
if ATTR_CODE not in service.data:
|
||||||
return
|
return
|
||||||
|
|
||||||
code = service.data[ATTR_CODE]
|
code = service.data[ATTR_CODE]
|
||||||
|
|
||||||
method = SERVICE_TO_METHOD[service.service]
|
method = SERVICE_TO_METHOD[service.service]
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ def alarm_disarm(hass, code, entity_id=None):
|
|||||||
data[ATTR_ENTITY_ID] = entity_id
|
data[ATTR_ENTITY_ID] = entity_id
|
||||||
|
|
||||||
hass.services.call(DOMAIN, SERVICE_ALARM_DISARM, data)
|
hass.services.call(DOMAIN, SERVICE_ALARM_DISARM, data)
|
||||||
|
|
||||||
|
|
||||||
def alarm_arm_home(hass, code, entity_id=None):
|
def alarm_arm_home(hass, code, entity_id=None):
|
||||||
""" Send the alarm the command for arm home. """
|
""" 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)
|
hass.services.call(DOMAIN, SERVICE_ALARM_ARM_HOME, data)
|
||||||
|
|
||||||
|
|
||||||
def alarm_arm_away(hass, code, entity_id=None):
|
def alarm_arm_away(hass, code, entity_id=None):
|
||||||
""" Send the alarm the command for arm away. """
|
""" Send the alarm the command for arm away. """
|
||||||
data = {ATTR_CODE: code}
|
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)
|
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):
|
def alarm_disarm(self, code):
|
||||||
""" Send disar command. """
|
""" Send disarm command. """
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def alarm_arm_home(self, code):
|
def alarm_arm_home(self, code):
|
||||||
""" Send pause command. """
|
""" Send pause command. """
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def alarm_arm_away(self, code):
|
def alarm_arm_away(self, code):
|
||||||
""" Send pause command. """
|
""" Send pause command. """
|
||||||
raise NotImplementedError()
|
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 logging
|
||||||
|
|
||||||
import homeassistant.components.verisure as verisure
|
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 (
|
||||||
from homeassistant.const import (STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY)
|
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
add_devices(alarms)
|
add_devices(alarms)
|
||||||
|
|
||||||
|
|
||||||
class VerisureAlarm(alarm.AlarmControl):
|
class VerisureAlarm(alarm.AlarmControlPanel):
|
||||||
""" represents a Verisure alarm status within home assistant. """
|
""" represents a Verisure alarm status within home assistant. """
|
||||||
|
|
||||||
def __init__(self, alarm_status):
|
def __init__(self, alarm_status):
|
||||||
@ -56,24 +56,32 @@ class VerisureAlarm(alarm.AlarmControl):
|
|||||||
elif verisure.STATUS[self._device][self._id].status == 'armedaway':
|
elif verisure.STATUS[self._device][self._id].status == 'armedaway':
|
||||||
self._state = STATE_ALARM_ARMED_AWAY
|
self._state = STATE_ALARM_ARMED_AWAY
|
||||||
elif verisure.STATUS[self._device][self._id].status != 'pending':
|
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
|
return self._state
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
''' update alarm status '''
|
''' update alarm status '''
|
||||||
verisure.update()
|
verisure.update()
|
||||||
|
|
||||||
def alarm_disarm(self, code):
|
def alarm_disarm(self, code):
|
||||||
""" Send disarm command. """
|
""" Send disarm command. """
|
||||||
verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_DISARMED)
|
verisure.MY_PAGES.set_alarm_status(
|
||||||
_LOGGER.warning('disarming')
|
code,
|
||||||
|
verisure.MY_PAGES.ALARM_DISARMED)
|
||||||
|
_LOGGER.warning('disarming')
|
||||||
|
|
||||||
def alarm_arm_home(self, code):
|
def alarm_arm_home(self, code):
|
||||||
""" Send arm home command. """
|
""" Send arm home command. """
|
||||||
verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_ARMED_HOME)
|
verisure.MY_PAGES.set_alarm_status(
|
||||||
_LOGGER.warning('arming home')
|
code,
|
||||||
|
verisure.MY_PAGES.ALARM_ARMED_HOME)
|
||||||
|
_LOGGER.warning('arming home')
|
||||||
|
|
||||||
def alarm_arm_away(self, code):
|
def alarm_arm_away(self, code):
|
||||||
""" Send arm away command. """
|
""" Send arm away command. """
|
||||||
verisure.MY_PAGES.set_alarm_status(code, verisure.MY_PAGES.ALARM_ARMED_AWAY)
|
verisure.MY_PAGES.set_alarm_status(
|
||||||
_LOGGER.warning('arming away')
|
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"
|
DOMAIN = "verisure"
|
||||||
DISCOVER_SENSORS = 'verisure.sensors'
|
DISCOVER_SENSORS = 'verisure.sensors'
|
||||||
DISCOVER_SWITCHES = 'verisure.switches'
|
DISCOVER_SWITCHES = 'verisure.switches'
|
||||||
DISCOVER_ALARMS = 'verisure.alarms'
|
DISCOVER_ALARMS = 'verisure.alarms_control_panel'
|
||||||
|
|
||||||
DEPENDENCIES = ['alarm']
|
DEPENDENCIES = ['alarm_control_panel']
|
||||||
REQUIREMENTS = [
|
REQUIREMENTS = [
|
||||||
'https://github.com/persandstrom/python-verisure/archive/master.zip'
|
'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,
|
# custom_components/switch/some_platform.py exists,
|
||||||
# the import custom_components.switch would succeeed.
|
# the import custom_components.switch would succeeed.
|
||||||
if module.__spec__.origin == 'namespace':
|
if module.__spec__.origin == 'namespace':
|
||||||
|
|
||||||
print("!!!!!!!!!!!!!!!!!!!!! " + module.__spec__.origin)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
_LOGGER.info("Loaded %s from %s", comp_name, path)
|
_LOGGER.info("Loaded %s from %s", comp_name, path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user