Skip to content

Commit

Permalink
Update service domain for elkm1 from 'alarm_control_panel' to 'elkm1' (
Browse files Browse the repository at this point in the history
…#29128)

* move elkm1 services to elkm1 domain

* update missed variable references
  • Loading branch information
raman325 authored and pvizeli committed Nov 27, 2019
1 parent b7896c7 commit 975ee0e
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 69 deletions.
52 changes: 0 additions & 52 deletions homeassistant/components/alarm_control_panel/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 5 additions & 0 deletions homeassistant/components/elkm1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@

_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",
Expand Down
35 changes: 23 additions & 12 deletions homeassistant/components/elkm1/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,7 +28,15 @@
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"
Expand Down Expand Up @@ -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"]
Expand All @@ -75,7 +86,7 @@ def _arm_service(service):

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):
Expand All @@ -91,22 +102,22 @@ def _display_message_service(service):
_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,
)


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):
Expand All @@ -133,15 +144,15 @@ def _watch_keypad(self, keypad, changeset):
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)

@property
def code_format(self):
"""Return the alarm code format."""
return alarm.FORMAT_NUMBER
return FORMAT_NUMBER

@property
def state(self):
Expand Down
63 changes: 58 additions & 5 deletions homeassistant/components/elkm1/services.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 975ee0e

Please sign in to comment.