Update service domain for ifttt from 'alarm_control_panel' to 'ifttt' (#29129)

* update service domain for ifttt

* update missed variable references
This commit is contained in:
Raman Gupta 2019-11-27 12:17:56 -05:00 committed by Pascal Vizeli
parent 82fe409961
commit 8ef8a314df
4 changed files with 22 additions and 20 deletions

View File

@ -69,13 +69,3 @@ alarmdecoder_alarm_toggle_chime:
code: code:
description: A required code to toggle the alarm control panel chime with. description: A required code to toggle the alarm control panel chime with.
example: 1234 example: 1234
ifttt_push_alarm_state:
description: Update the alarm state to the specified value.
fields:
entity_id:
description: Name of the alarm control panel which state has to be updated.
example: 'alarm_control_panel.downstairs'
state:
description: The state to which the alarm control panel has to be set.
example: 'armed_night'

View File

@ -23,6 +23,7 @@ ATTR_VALUE3 = "value3"
CONF_KEY = "key" CONF_KEY = "key"
SERVICE_PUSH_ALARM_STATE = "push_alarm_state"
SERVICE_TRIGGER = "trigger" SERVICE_TRIGGER = "trigger"
SERVICE_TRIGGER_SCHEMA = vol.Schema( SERVICE_TRIGGER_SCHEMA = vol.Schema(

View File

@ -4,8 +4,12 @@ import re
import voluptuous as vol import voluptuous as vol
import homeassistant.components.alarm_control_panel as alarm from homeassistant.components.alarm_control_panel import (
from homeassistant.components.alarm_control_panel import DOMAIN, PLATFORM_SCHEMA AlarmControlPanel,
FORMAT_NUMBER,
FORMAT_TEXT,
)
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
from homeassistant.components.alarm_control_panel.const import ( from homeassistant.components.alarm_control_panel.const import (
SUPPORT_ALARM_ARM_AWAY, SUPPORT_ALARM_ARM_AWAY,
SUPPORT_ALARM_ARM_HOME, SUPPORT_ALARM_ARM_HOME,
@ -24,7 +28,7 @@ from homeassistant.const import (
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from . import ATTR_EVENT, DOMAIN as IFTTT_DOMAIN, SERVICE_TRIGGER from . import ATTR_EVENT, DOMAIN, SERVICE_PUSH_ALARM_STATE, SERVICE_TRIGGER
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -60,8 +64,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
} }
) )
SERVICE_PUSH_ALARM_STATE = "ifttt_push_alarm_state"
PUSH_ALARM_STATE_SERVICE_SCHEMA = vol.Schema( PUSH_ALARM_STATE_SERVICE_SCHEMA = vol.Schema(
{vol.Required(ATTR_ENTITY_ID): cv.entity_ids, vol.Required(ATTR_STATE): cv.string} {vol.Required(ATTR_ENTITY_ID): cv.entity_ids, vol.Required(ATTR_STATE): cv.string}
) )
@ -106,7 +108,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
) )
class IFTTTAlarmPanel(alarm.AlarmControlPanel): class IFTTTAlarmPanel(AlarmControlPanel):
"""Representation of an alarm control panel controlled through IFTTT.""" """Representation of an alarm control panel controlled through IFTTT."""
def __init__( def __init__(
@ -148,8 +150,8 @@ class IFTTTAlarmPanel(alarm.AlarmControlPanel):
if self._code is None: if self._code is None:
return None return None
if isinstance(self._code, str) and re.search("^\\d+$", self._code): if isinstance(self._code, str) and re.search("^\\d+$", self._code):
return alarm.FORMAT_NUMBER return FORMAT_NUMBER
return alarm.FORMAT_TEXT return FORMAT_TEXT
def alarm_disarm(self, code=None): def alarm_disarm(self, code=None):
"""Send disarm command.""" """Send disarm command."""
@ -179,7 +181,7 @@ class IFTTTAlarmPanel(alarm.AlarmControlPanel):
"""Call the IFTTT trigger service to change the alarm state.""" """Call the IFTTT trigger service to change the alarm state."""
data = {ATTR_EVENT: event} data = {ATTR_EVENT: event}
self.hass.services.call(IFTTT_DOMAIN, SERVICE_TRIGGER, data) self.hass.services.call(DOMAIN, SERVICE_TRIGGER, data)
_LOGGER.debug("Called IFTTT integration to trigger event %s", event) _LOGGER.debug("Called IFTTT integration to trigger event %s", event)
if self._optimistic: if self._optimistic:
self._state = state self._state = state

View File

@ -1,5 +1,14 @@
# Describes the format for available ifttt services # Describes the format for available ifttt services
push_alarm_state:
description: Update the alarm state to the specified value.
fields:
entity_id:
description: Name of the alarm control panel which state has to be updated.
example: 'alarm_control_panel.downstairs'
state:
description: The state to which the alarm control panel has to be set.
example: 'armed_night'
trigger: trigger:
description: Triggers the configured IFTTT Webhook. description: Triggers the configured IFTTT Webhook.