456 files
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -35,6 +35,10 @@ class SpookService(AbstractSpookAdminService):
|
||||
async_check_labels_exist(self.hass, call.data["label_id"])
|
||||
|
||||
area_registry = ar.async_get(self.hass)
|
||||
|
||||
# Everything is looked up before anything is written. A typo in the
|
||||
# last one should not leave the first ones changed behind an error.
|
||||
updates: dict[str, set[str]] = {}
|
||||
for area_id in call.data["area_id"]:
|
||||
if (area_entry := area_registry.async_get_area(area_id)) is None:
|
||||
msg = f"Area {area_id} not found"
|
||||
@@ -42,4 +46,7 @@ class SpookService(AbstractSpookAdminService):
|
||||
|
||||
labels = area_entry.labels.copy()
|
||||
labels.update(call.data["label_id"])
|
||||
updates[area_id] = labels
|
||||
|
||||
for area_id, labels in updates.items():
|
||||
area_registry.async_update(area_id, labels=labels)
|
||||
|
||||
@@ -36,6 +36,10 @@ class SpookService(AbstractSpookAdminService):
|
||||
async_check_labels_exist(self.hass, call.data["label_id"])
|
||||
|
||||
device_registry = dr.async_get(self.hass)
|
||||
|
||||
# Everything is looked up before anything is written. A typo in the
|
||||
# last one should not leave the first ones changed behind an error.
|
||||
updates: dict[str, set[str]] = {}
|
||||
for device_id in call.data["device_id"]:
|
||||
if (device_entry := device_registry.async_get(device_id)) is None:
|
||||
msg = f"Device {device_id} not found"
|
||||
@@ -43,4 +47,7 @@ class SpookService(AbstractSpookAdminService):
|
||||
|
||||
labels = device_entry.labels.copy()
|
||||
labels.update(call.data["label_id"])
|
||||
updates[device_id] = labels
|
||||
|
||||
for device_id, labels in updates.items():
|
||||
async_update_any_device(device_registry, device_id, labels=labels)
|
||||
|
||||
@@ -35,6 +35,10 @@ class SpookService(AbstractSpookAdminService):
|
||||
async_check_labels_exist(self.hass, call.data["label_id"])
|
||||
|
||||
entity_registry = er.async_get(self.hass)
|
||||
|
||||
# Everything is looked up before anything is written. A typo in the
|
||||
# last one should not leave the first ones changed behind an error.
|
||||
updates: dict[str, set[str]] = {}
|
||||
for entity_id in call.data["entity_id"]:
|
||||
if (entity_entry := entity_registry.async_get(entity_id)) is None:
|
||||
msg = f"Entity {entity_id} not found"
|
||||
@@ -42,4 +46,7 @@ class SpookService(AbstractSpookAdminService):
|
||||
|
||||
labels = entity_entry.labels.copy()
|
||||
labels.update(call.data["label_id"])
|
||||
updates[entity_id] = labels
|
||||
|
||||
for entity_id, labels in updates.items():
|
||||
entity_registry.async_update_entity(entity_id, labels=labels)
|
||||
|
||||
@@ -25,6 +25,9 @@ class SpookService(AbstractSpookAdminService):
|
||||
|
||||
async def async_handle_service(self, call: ServiceCall) -> None:
|
||||
"""Handle the service call."""
|
||||
# Everything is looked up before anything is written. A bad one late
|
||||
# in the list should not leave the first ones changed behind an error.
|
||||
users = []
|
||||
for user_id in call.data["user_id"]:
|
||||
user = await self.hass.auth.async_get_user(user_id)
|
||||
if user is None:
|
||||
@@ -33,4 +36,7 @@ class SpookService(AbstractSpookAdminService):
|
||||
if user.system_generated:
|
||||
message = f"Cannot disable a system-generated user: {user_id}"
|
||||
raise HomeAssistantError(message)
|
||||
users.append(user)
|
||||
|
||||
for user in users:
|
||||
await self.hass.auth.async_update_user(user, is_active=False)
|
||||
|
||||
@@ -25,6 +25,9 @@ class SpookService(AbstractSpookAdminService):
|
||||
|
||||
async def async_handle_service(self, call: ServiceCall) -> None:
|
||||
"""Handle the service call."""
|
||||
# Everything is looked up before anything is written. A bad one late
|
||||
# in the list should not leave the first ones changed behind an error.
|
||||
users = []
|
||||
for user_id in call.data["user_id"]:
|
||||
user = await self.hass.auth.async_get_user(user_id)
|
||||
if user is None:
|
||||
@@ -33,4 +36,7 @@ class SpookService(AbstractSpookAdminService):
|
||||
if user.system_generated:
|
||||
message = f"Cannot enable a system-generated user: {user_id}"
|
||||
raise HomeAssistantError(message)
|
||||
users.append(user)
|
||||
|
||||
for user in users:
|
||||
await self.hass.auth.async_update_user(user, is_active=True)
|
||||
|
||||
@@ -35,6 +35,10 @@ class SpookService(AbstractSpookAdminService):
|
||||
async_check_labels_exist(self.hass, call.data["label_id"])
|
||||
|
||||
area_registry = ar.async_get(self.hass)
|
||||
|
||||
# Everything is looked up before anything is written. A typo in the
|
||||
# last one should not leave the first ones changed behind an error.
|
||||
updates: dict[str, set[str]] = {}
|
||||
for area_id in call.data["area_id"]:
|
||||
if (area_entry := area_registry.async_get_area(area_id)) is None:
|
||||
msg = f"Area {area_id} not found"
|
||||
@@ -42,4 +46,7 @@ class SpookService(AbstractSpookAdminService):
|
||||
|
||||
labels = area_entry.labels.copy()
|
||||
labels.difference_update(call.data["label_id"])
|
||||
updates[area_id] = labels
|
||||
|
||||
for area_id, labels in updates.items():
|
||||
area_registry.async_update(area_id, labels=labels)
|
||||
|
||||
@@ -36,6 +36,10 @@ class SpookService(AbstractSpookAdminService):
|
||||
async_check_labels_exist(self.hass, call.data["label_id"])
|
||||
|
||||
device_registry = dr.async_get(self.hass)
|
||||
|
||||
# Everything is looked up before anything is written. A typo in the
|
||||
# last one should not leave the first ones changed behind an error.
|
||||
updates: dict[str, set[str]] = {}
|
||||
for device_id in call.data["device_id"]:
|
||||
if (device_entry := device_registry.async_get(device_id)) is None:
|
||||
msg = f"Device {device_id} not found"
|
||||
@@ -43,4 +47,7 @@ class SpookService(AbstractSpookAdminService):
|
||||
|
||||
labels = device_entry.labels.copy()
|
||||
labels.difference_update(call.data["label_id"])
|
||||
updates[device_id] = labels
|
||||
|
||||
for device_id, labels in updates.items():
|
||||
async_update_any_device(device_registry, device_id, labels=labels)
|
||||
|
||||
@@ -35,6 +35,10 @@ class SpookService(AbstractSpookAdminService):
|
||||
async_check_labels_exist(self.hass, call.data["label_id"])
|
||||
|
||||
entity_registry = er.async_get(self.hass)
|
||||
|
||||
# Everything is looked up before anything is written. A typo in the
|
||||
# last one should not leave the first ones changed behind an error.
|
||||
updates: dict[str, set[str]] = {}
|
||||
for entity_id in call.data["entity_id"]:
|
||||
if (entity_entry := entity_registry.async_get(entity_id)) is None:
|
||||
msg = f"Entity {entity_id} not found"
|
||||
@@ -42,4 +46,7 @@ class SpookService(AbstractSpookAdminService):
|
||||
|
||||
labels = entity_entry.labels.copy()
|
||||
labels.difference_update(call.data["label_id"])
|
||||
updates[entity_id] = labels
|
||||
|
||||
for entity_id, labels in updates.items():
|
||||
entity_registry.async_update_entity(entity_id, labels=labels)
|
||||
|
||||
Reference in New Issue
Block a user