mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add a keypress service for AlarmDecoder (#26100)
* Add a keypress service for AlarmDecoder (like Envisalink has) * Feedback * Import DOMAIN
This commit is contained in:
parent
fade2e991b
commit
5ba436e3d8
@ -13,13 +13,17 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
from . import DATA_AD, SIGNAL_PANEL_MESSAGE
|
from . import DATA_AD, DOMAIN as DOMAIN_ALARMDECODER, SIGNAL_PANEL_MESSAGE
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SERVICE_ALARM_TOGGLE_CHIME = "alarmdecoder_alarm_toggle_chime"
|
SERVICE_ALARM_TOGGLE_CHIME = "alarmdecoder_alarm_toggle_chime"
|
||||||
ALARM_TOGGLE_CHIME_SCHEMA = vol.Schema({vol.Required(ATTR_CODE): cv.string})
|
ALARM_TOGGLE_CHIME_SCHEMA = vol.Schema({vol.Required(ATTR_CODE): cv.string})
|
||||||
|
|
||||||
|
SERVICE_ALARM_KEYPRESS = "alarm_keypress"
|
||||||
|
ATTR_KEYPRESS = "keypress"
|
||||||
|
ALARM_KEYPRESS_SCHEMA = vol.Schema({vol.Required(ATTR_KEYPRESS): cv.string})
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up for AlarmDecoder alarm panels."""
|
"""Set up for AlarmDecoder alarm panels."""
|
||||||
@ -38,6 +42,18 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
schema=ALARM_TOGGLE_CHIME_SCHEMA,
|
schema=ALARM_TOGGLE_CHIME_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def alarm_keypress_handler(service):
|
||||||
|
"""Register keypress handler."""
|
||||||
|
keypress = service.data[ATTR_KEYPRESS]
|
||||||
|
device.alarm_keypress(keypress)
|
||||||
|
|
||||||
|
hass.services.register(
|
||||||
|
DOMAIN_ALARMDECODER,
|
||||||
|
SERVICE_ALARM_KEYPRESS,
|
||||||
|
alarm_keypress_handler,
|
||||||
|
schema=ALARM_KEYPRESS_SCHEMA,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AlarmDecoderAlarmPanel(alarm.AlarmControlPanel):
|
class AlarmDecoderAlarmPanel(alarm.AlarmControlPanel):
|
||||||
"""Representation of an AlarmDecoder-based alarm panel."""
|
"""Representation of an AlarmDecoder-based alarm panel."""
|
||||||
@ -145,3 +161,8 @@ class AlarmDecoderAlarmPanel(alarm.AlarmControlPanel):
|
|||||||
"""Send toggle chime command."""
|
"""Send toggle chime command."""
|
||||||
if code:
|
if code:
|
||||||
self.hass.data[DATA_AD].send("{!s}9".format(code))
|
self.hass.data[DATA_AD].send("{!s}9".format(code))
|
||||||
|
|
||||||
|
def alarm_keypress(self, keypress):
|
||||||
|
"""Send custom keypresses."""
|
||||||
|
if keypress:
|
||||||
|
self.hass.data[DATA_AD].send(keypress)
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
alarm_keypress:
|
||||||
|
description: Send custom keypresses to the alarm.
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name of the alarm control panel to trigger.
|
||||||
|
example: 'alarm_control_panel.downstairs'
|
||||||
|
keypress:
|
||||||
|
description: 'String to send to the alarm panel.'
|
||||||
|
example: '*71'
|
Loading…
x
Reference in New Issue
Block a user