1 """Services for the Blink integration."""
3 from __future__
import annotations
5 import voluptuous
as vol
13 from .const
import ATTR_CONFIG_ENTRY_ID, DOMAIN, SERVICE_SEND_PIN
14 from .coordinator
import BlinkConfigEntry
16 SERVICE_UPDATE_SCHEMA = vol.Schema(
18 vol.Required(ATTR_DEVICE_ID): vol.All(cv.ensure_list, [cv.string]),
21 SERVICE_SEND_PIN_SCHEMA = vol.Schema(
23 vol.Required(ATTR_CONFIG_ENTRY_ID): vol.All(cv.ensure_list, [cv.string]),
24 vol.Optional(CONF_PIN): cv.string,
30 """Set up the services for the Blink integration."""
32 async
def send_pin(call: ServiceCall):
33 """Call blink to send new pin."""
34 config_entry: BlinkConfigEntry |
None
35 for entry_id
in call.data[ATTR_CONFIG_ENTRY_ID]:
36 if not (config_entry := hass.config_entries.async_get_entry(entry_id)):
38 translation_domain=DOMAIN,
39 translation_key=
"integration_not_found",
40 translation_placeholders={
"target": DOMAIN},
42 if config_entry.state != ConfigEntryState.LOADED:
44 translation_domain=DOMAIN,
45 translation_key=
"not_loaded",
46 translation_placeholders={
"target": config_entry.title},
48 coordinator = config_entry.runtime_data
49 await coordinator.api.auth.send_auth_key(
54 hass.services.async_register(
58 schema=SERVICE_SEND_PIN_SCHEMA,
None setup_services(HomeAssistant hass)