Update service domain for elkm1 from 'alarm_control_panel' to 'elkm1' (#29128)

* move elkm1 services to elkm1 domain

* update missed variable references
This commit is contained in:
Raman Gupta 2019-11-27 05:15:27 -05:00 committed by Pascal Vizeli
parent b7896c7b6f
commit 975ee0ea7f
4 changed files with 86 additions and 69 deletions

View file

@ -89,55 +89,3 @@ ifttt_push_alarm_state:
state:
description: The state to which the alarm control panel has to be set.
example: 'armed_night'
elkm1_alarm_arm_vacation:
description: Arm the ElkM1 in vacation mode.
fields:
entity_id:
description: Name of alarm control panel to arm.
example: 'alarm_control_panel.main'
code:
description: An code to arm the alarm control panel.
example: 1234
elkm1_alarm_arm_home_instant:
description: Arm the ElkM1 in home instant mode.
fields:
entity_id:
description: Name of alarm control panel to arm.
example: 'alarm_control_panel.main'
code:
description: An code to arm the alarm control panel.
example: 1234
elkm1_alarm_arm_night_instant:
description: Arm the ElkM1 in night instant mode.
fields:
entity_id:
description: Name of alarm control panel to arm.
example: 'alarm_control_panel.main'
code:
description: An code to arm the alarm control panel.
example: 1234
elkm1_alarm_display_message:
description: Display a message on all of the ElkM1 keypads for an area.
fields:
entity_id:
description: Name of alarm control panel to display messages on.
example: 'alarm_control_panel.main'
clear:
description: 0=clear message, 1=clear message with * key, 2=Display until timeout; default 2
example: 1
beep:
description: 0=no beep, 1=beep; default 0
example: 1
timeout:
description: Time to display message, 0=forever, max 65535, default 0
example: 4242
line1:
description: Up to 16 characters of text (truncated if too long). Default blank.
example: The answer to life,
line2:
description: Up to 16 characters of text (truncated if too long). Default blank.
example: the universe, and everything.

View file

@ -35,6 +35,11 @@ CONF_PREFIX = "prefix"
_LOGGER = logging.getLogger(__name__)
SERVICE_ALARM_DISPLAY_MESSAGE = "alarm_display_message"
SERVICE_ALARM_ARM_VACATION = "alarm_arm_vacation"
SERVICE_ALARM_ARM_HOME_INSTANT = "alarm_arm_home_instant"
SERVICE_ALARM_ARM_NIGHT_INSTANT = "alarm_arm_night_instant"
SUPPORTED_DOMAINS = [
"alarm_control_panel",
"climate",

View file

@ -2,7 +2,10 @@
from elkm1_lib.const import AlarmState, ArmedStatus, ArmLevel, ArmUpState
import voluptuous as vol
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel import (
AlarmControlPanel,
FORMAT_NUMBER,
)
from homeassistant.components.alarm_control_panel.const import (
SUPPORT_ALARM_ARM_AWAY,
SUPPORT_ALARM_ARM_HOME,
@ -25,7 +28,15 @@ from homeassistant.helpers.dispatcher import (
async_dispatcher_send,
)
from . import DOMAIN as ELK_DOMAIN, ElkEntity, create_elk_entities
from . import (
create_elk_entities,
DOMAIN,
ElkEntity,
SERVICE_ALARM_ARM_HOME_INSTANT,
SERVICE_ALARM_ARM_NIGHT_INSTANT,
SERVICE_ALARM_ARM_VACATION,
SERVICE_ALARM_DISPLAY_MESSAGE,
)
SIGNAL_ARM_ENTITY = "elkm1_arm"
SIGNAL_DISPLAY_MESSAGE = "elkm1_display_message"
@ -56,7 +67,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
if discovery_info is None:
return
elk_datas = hass.data[ELK_DOMAIN]
elk_datas = hass.data[DOMAIN]
entities = []
for elk_data in elk_datas.values():
elk = elk_data["elk"]
@ -75,7 +86,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
for service in _arm_services():
hass.services.async_register(
alarm.DOMAIN, service, _arm_service, ELK_ALARM_SERVICE_SCHEMA
DOMAIN, service, _arm_service, ELK_ALARM_SERVICE_SCHEMA
)
def _display_message_service(service):
@ -91,8 +102,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
_dispatch(SIGNAL_DISPLAY_MESSAGE, entity_ids, *args)
hass.services.async_register(
alarm.DOMAIN,
"elkm1_alarm_display_message",
DOMAIN,
SERVICE_ALARM_DISPLAY_MESSAGE,
_display_message_service,
DISPLAY_MESSAGE_SERVICE_SCHEMA,
)
@ -100,13 +111,13 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
def _arm_services():
return {
"elkm1_alarm_arm_vacation": ArmLevel.ARMED_VACATION.value,
"elkm1_alarm_arm_home_instant": ArmLevel.ARMED_STAY_INSTANT.value,
"elkm1_alarm_arm_night_instant": ArmLevel.ARMED_NIGHT_INSTANT.value,
SERVICE_ALARM_ARM_VACATION: ArmLevel.ARMED_VACATION.value,
SERVICE_ALARM_ARM_HOME_INSTANT: ArmLevel.ARMED_STAY_INSTANT.value,
SERVICE_ALARM_ARM_NIGHT_INSTANT: ArmLevel.ARMED_NIGHT_INSTANT.value,
}
class ElkArea(ElkEntity, alarm.AlarmControlPanel):
class ElkArea(ElkEntity, AlarmControlPanel):
"""Representation of an Area / Partition within the ElkM1 alarm panel."""
def __init__(self, element, elk, elk_data):
@ -133,7 +144,7 @@ class ElkArea(ElkEntity, alarm.AlarmControlPanel):
if keypad.area != self._element.index:
return
if changeset.get("last_user") is not None:
self._changed_by_entity_id = self.hass.data[ELK_DOMAIN][self._prefix][
self._changed_by_entity_id = self.hass.data[DOMAIN][self._prefix][
"keypads"
].get(keypad.index, "")
self.async_schedule_update_ha_state(True)
@ -141,7 +152,7 @@ class ElkArea(ElkEntity, alarm.AlarmControlPanel):
@property
def code_format(self):
"""Return the alarm code format."""
return alarm.FORMAT_NUMBER
return FORMAT_NUMBER
@property
def state(self):

View file

@ -1,12 +1,65 @@
speak_word:
description: Speak a word. See list of words in ElkM1 ASCII Protocol documentation.
alarm_arm_home_instant:
description: Arm the ElkM1 in home instant mode.
fields:
number:
description: Word number to speak.
example: 142
entity_id:
description: Name of alarm control panel to arm.
example: 'alarm_control_panel.main'
code:
description: An code to arm the alarm control panel.
example: 1234
alarm_arm_night_instant:
description: Arm the ElkM1 in night instant mode.
fields:
entity_id:
description: Name of alarm control panel to arm.
example: 'alarm_control_panel.main'
code:
description: An code to arm the alarm control panel.
example: 1234
alarm_arm_vacation:
description: Arm the ElkM1 in vacation mode.
fields:
entity_id:
description: Name of alarm control panel to arm.
example: 'alarm_control_panel.main'
code:
description: An code to arm the alarm control panel.
example: 1234
alarm_display_message:
description: Display a message on all of the ElkM1 keypads for an area.
fields:
entity_id:
description: Name of alarm control panel to display messages on.
example: 'alarm_control_panel.main'
clear:
description: 0=clear message, 1=clear message with * key, 2=Display until timeout; default 2
example: 1
beep:
description: 0=no beep, 1=beep; default 0
example: 1
timeout:
description: Time to display message, 0=forever, max 65535, default 0
example: 4242
line1:
description: Up to 16 characters of text (truncated if too long). Default blank.
example: The answer to life,
line2:
description: Up to 16 characters of text (truncated if too long). Default blank.
example: the universe, and everything.
speak_phrase:
description: Speak a phrase. See list of phrases in ElkM1 ASCII Protocol documentation.
fields:
number:
description: Phrase number to speak.
example: 42
speak_word:
description: Speak a word. See list of words in ElkM1 ASCII Protocol documentation.
fields:
number:
description: Word number to speak.
example: 142