mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Add services to set and remove Simplisafe PINs (#25207)
* Add services to set and remove SimpliSafe PINs * Added services spec * Add services to set and remove SimpliSafe PINs * Member comments * Missed one
This commit is contained in:
parent
1c6d55e51b
commit
003f7865a9
@ -13,6 +13,7 @@ from homeassistant.exceptions import ConfigEntryNotReady
|
|||||||
from homeassistant.helpers import aiohttp_client, device_registry as dr
|
from homeassistant.helpers import aiohttp_client, device_registry as dr
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
|
from homeassistant.helpers.service import verify_domain_control
|
||||||
|
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
@ -21,10 +22,26 @@ from .const import DATA_CLIENT, DEFAULT_SCAN_INTERVAL, DOMAIN, TOPIC_UPDATE
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
ATTR_PIN_LABEL = 'label'
|
||||||
|
ATTR_PIN_LABEL_OR_VALUE = 'label_or_pin'
|
||||||
|
ATTR_PIN_VALUE = 'pin'
|
||||||
|
ATTR_SYSTEM_ID = 'system_id'
|
||||||
|
|
||||||
CONF_ACCOUNTS = 'accounts'
|
CONF_ACCOUNTS = 'accounts'
|
||||||
|
|
||||||
DATA_LISTENER = 'listener'
|
DATA_LISTENER = 'listener'
|
||||||
|
|
||||||
|
SERVICE_REMOVE_PIN_SCHEMA = vol.Schema({
|
||||||
|
vol.Required(ATTR_SYSTEM_ID): cv.string,
|
||||||
|
vol.Required(ATTR_PIN_LABEL_OR_VALUE): cv.string,
|
||||||
|
})
|
||||||
|
|
||||||
|
SERVICE_SET_PIN_SCHEMA = vol.Schema({
|
||||||
|
vol.Required(ATTR_SYSTEM_ID): cv.string,
|
||||||
|
vol.Required(ATTR_PIN_LABEL): cv.string,
|
||||||
|
vol.Required(ATTR_PIN_VALUE): cv.string,
|
||||||
|
})
|
||||||
|
|
||||||
ACCOUNT_CONFIG_SCHEMA = vol.Schema({
|
ACCOUNT_CONFIG_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
vol.Required(CONF_USERNAME): cv.string,
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
vol.Required(CONF_PASSWORD): cv.string,
|
||||||
@ -97,6 +114,8 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
from simplipy import API
|
from simplipy import API
|
||||||
from simplipy.errors import InvalidCredentialsError, SimplipyError
|
from simplipy.errors import InvalidCredentialsError, SimplipyError
|
||||||
|
|
||||||
|
_verify_domain_control = verify_domain_control(hass, DOMAIN)
|
||||||
|
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -149,6 +168,25 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
async_register_base_station(
|
async_register_base_station(
|
||||||
hass, system, config_entry.entry_id))
|
hass, system, config_entry.entry_id))
|
||||||
|
|
||||||
|
@_verify_domain_control
|
||||||
|
async def remove_pin(call):
|
||||||
|
"""Remove a PIN."""
|
||||||
|
system = systems[int(call.data[ATTR_SYSTEM_ID])]
|
||||||
|
await system.remove_pin(call.data[ATTR_PIN_LABEL_OR_VALUE])
|
||||||
|
|
||||||
|
@_verify_domain_control
|
||||||
|
async def set_pin(call):
|
||||||
|
"""Set a PIN."""
|
||||||
|
system = systems[int(call.data[ATTR_SYSTEM_ID])]
|
||||||
|
await system.set_pin(
|
||||||
|
call.data[ATTR_PIN_LABEL], call.data[ATTR_PIN_VALUE])
|
||||||
|
|
||||||
|
for service, method, schema in [
|
||||||
|
('remove_pin', remove_pin, SERVICE_REMOVE_PIN_SCHEMA),
|
||||||
|
('set_pin', set_pin, SERVICE_SET_PIN_SCHEMA),
|
||||||
|
]:
|
||||||
|
hass.services.async_register(DOMAIN, service, method, schema=schema)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/components/simplisafe",
|
"documentation": "https://www.home-assistant.io/components/simplisafe",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"simplisafe-python==4.0.0"
|
"simplisafe-python==4.0.1"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
|
24
homeassistant/components/simplisafe/services.yaml
Normal file
24
homeassistant/components/simplisafe/services.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Describes the format for available SimpliSafe services
|
||||||
|
|
||||||
|
---
|
||||||
|
remove_pin:
|
||||||
|
description: Remove a PIN by its label or value.
|
||||||
|
fields:
|
||||||
|
system_id:
|
||||||
|
description: The SimpliSafe system ID to affect.
|
||||||
|
example: 123987
|
||||||
|
label_or_pin:
|
||||||
|
description: The label/value to remove.
|
||||||
|
example: Test PIN
|
||||||
|
set_pin:
|
||||||
|
description: Set/update a PIN
|
||||||
|
fields:
|
||||||
|
system_id:
|
||||||
|
description: The SimpliSafe system ID to affect.
|
||||||
|
example: 123987
|
||||||
|
label:
|
||||||
|
description: The label of the PIN
|
||||||
|
example: Test PIN
|
||||||
|
pin:
|
||||||
|
description: The value of the PIN
|
||||||
|
example: 1256
|
@ -1679,7 +1679,7 @@ shodan==1.13.0
|
|||||||
simplepush==1.1.4
|
simplepush==1.1.4
|
||||||
|
|
||||||
# homeassistant.components.simplisafe
|
# homeassistant.components.simplisafe
|
||||||
simplisafe-python==4.0.0
|
simplisafe-python==4.0.1
|
||||||
|
|
||||||
# homeassistant.components.sisyphus
|
# homeassistant.components.sisyphus
|
||||||
sisyphus-control==2.2
|
sisyphus-control==2.2
|
||||||
|
@ -334,7 +334,7 @@ ring_doorbell==0.2.3
|
|||||||
rxv==0.6.0
|
rxv==0.6.0
|
||||||
|
|
||||||
# homeassistant.components.simplisafe
|
# homeassistant.components.simplisafe
|
||||||
simplisafe-python==4.0.0
|
simplisafe-python==4.0.1
|
||||||
|
|
||||||
# homeassistant.components.sleepiq
|
# homeassistant.components.sleepiq
|
||||||
sleepyq==0.7
|
sleepyq==0.7
|
||||||
|
Loading…
x
Reference in New Issue
Block a user