Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions homeassistant/components/alarm_control_panel/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,3 @@ alarmdecoder_alarm_toggle_chime:
code:
description: A required code to toggle the alarm control panel chime with.
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'
1 change: 1 addition & 0 deletions homeassistant/components/ifttt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

CONF_KEY = "key"

SERVICE_PUSH_ALARM_STATE = "push_alarm_state"
SERVICE_TRIGGER = "trigger"

SERVICE_TRIGGER_SCHEMA = vol.Schema(
Expand Down
20 changes: 11 additions & 9 deletions homeassistant/components/ifttt/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

import voluptuous as vol

import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel import DOMAIN, PLATFORM_SCHEMA
from homeassistant.components.alarm_control_panel import (
AlarmControlPanel,
FORMAT_NUMBER,
FORMAT_TEXT,
)
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
from homeassistant.components.alarm_control_panel.const import (
SUPPORT_ALARM_ARM_AWAY,
SUPPORT_ALARM_ARM_HOME,
Expand All @@ -24,7 +28,7 @@
)
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__)

Expand Down Expand Up @@ -60,8 +64,6 @@
}
)

SERVICE_PUSH_ALARM_STATE = "ifttt_push_alarm_state"

PUSH_ALARM_STATE_SERVICE_SCHEMA = vol.Schema(
{vol.Required(ATTR_ENTITY_ID): cv.entity_ids, vol.Required(ATTR_STATE): cv.string}
)
Expand Down Expand Up @@ -106,7 +108,7 @@ async def push_state_update(service):
)


class IFTTTAlarmPanel(alarm.AlarmControlPanel):
class IFTTTAlarmPanel(AlarmControlPanel):
"""Representation of an alarm control panel controlled through IFTTT."""

def __init__(
Expand Down Expand Up @@ -148,8 +150,8 @@ def code_format(self):
if self._code is None:
return None
if isinstance(self._code, str) and re.search("^\\d+$", self._code):
return alarm.FORMAT_NUMBER
return alarm.FORMAT_TEXT
return FORMAT_NUMBER
return FORMAT_TEXT

def alarm_disarm(self, code=None):
"""Send disarm command."""
Expand Down Expand Up @@ -179,7 +181,7 @@ def set_alarm_state(self, event, state):
"""Call the IFTTT trigger service to change the alarm state."""
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)
if self._optimistic:
self._state = state
Expand Down
11 changes: 10 additions & 1 deletion homeassistant/components/ifttt/services.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# 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:
description: Triggers the configured IFTTT Webhook.
Expand All @@ -15,4 +24,4 @@ trigger:
example: 'some additional data'
value3:
description: Generic field to send data via the event.
example: 'even more data'
example: 'even more data'