Skip to content

Commit

Permalink
Fix accepting list of devices in enable/disable service (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Dec 8, 2023
1 parent ea62277 commit 16ae7fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ class SpookService(AbstractSpookAdminService):

domain = DOMAIN
service = "disable_device"
schema = {vol.Required("device_id"): cv.string}
schema = {vol.Required("device_id"): vol.All(cv.ensure_list, [cv.string])}

async def async_handle_service(self, call: ServiceCall) -> None:
"""Handle the service call."""
device_registry = dr.async_get(self.hass)
device_registry.async_update_device(
device_id=call.data["device_id"],
disabled_by=dr.DeviceEntryDisabler.USER,
)
for device_id in call.data["device_id"]:
device_registry.async_update_device(
device_id=device_id,
disabled_by=dr.DeviceEntryDisabler.USER,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ class SpookService(AbstractSpookAdminService):

domain = DOMAIN
service = "enable_device"
schema = {vol.Required("device_id"): cv.string}
schema = {vol.Required("device_id"): vol.All(cv.ensure_list, [cv.string])}

async def async_handle_service(self, call: ServiceCall) -> None:
"""Handle the service call."""
device_registry = dr.async_get(self.hass)
device_registry.async_update_device(
device_id=call.data["device_id"],
disabled_by=None,
)
for device_id in call.data["device_id"]:
device_registry.async_update_device(
device_id=device_id,
disabled_by=None,
)

0 comments on commit 16ae7fc

Please sign in to comment.