Skip to content

Commit

Permalink
Add bypass/unbypass services (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
chatziko authored Jul 1, 2022
1 parent b73de60 commit 7198c85
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions custom_components/ultrasync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
SERVICE_AWAY,
SERVICE_DISARM,
SERVICE_STAY,
SERVICE_BYPASS,
SERVICE_UNBYPASS,
)
from .coordinator import UltraSyncDataUpdateCoordinator

Expand Down Expand Up @@ -108,9 +110,19 @@ def disarm(call) -> None:
"""Service call to disable alarm in UltraSync Hub."""
coordinator.hub.set_alarm(state=AlarmScene.DISARMED)

def bypass(call) -> None:
"""Service call to bypass a zone in UltraSync Hub."""
coordinator.hub.set_zone_bypass(state=True, zone=call.data['zone'])

def unbypass(call) -> None:
"""Service call to unbypass a zone in UltraSync Hub."""
coordinator.hub.set_zone_bypass(state=False, zone=call.data['zone'])

hass.services.async_register(DOMAIN, SERVICE_AWAY, away, schema=vol.Schema({}))
hass.services.async_register(DOMAIN, SERVICE_STAY, stay, schema=vol.Schema({}))
hass.services.async_register(DOMAIN, SERVICE_DISARM, disarm, schema=vol.Schema({}))
hass.services.async_register(DOMAIN, SERVICE_BYPASS, bypass)
hass.services.async_register(DOMAIN, SERVICE_UNBYPASS, unbypass)


async def _async_update_listener(hass: HomeAssistantType, entry: ConfigEntry) -> None:
Expand Down
2 changes: 2 additions & 0 deletions custom_components/ultrasync/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
SERVICE_AWAY = "away"
SERVICE_STAY = "stay"
SERVICE_DISARM = "disarm"
SERVICE_BYPASS = "bypass"
SERVICE_UNBYPASS = "unbypass"

# Index used for managing loaded sensors
SENSORS = "sensors"
Expand Down
28 changes: 28 additions & 0 deletions custom_components/ultrasync/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,31 @@ stay:

disarm:
description: Disarm the Alarm

bypass:
description: Bypass a zone
fields:
zone:
name: Zone
description: The zone to bypass
required: true
example: 1
selector:
number:
mode: box
min: 1
max: 100

unbypass:
description: Unbypass a zone
fields:
zone:
name: Zone
description: The zone to unbypass
required: true
example: 1
selector:
number:
mode: box
min: 1
max: 100

0 comments on commit 7198c85

Please sign in to comment.