mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add WebSocket support for assigning labels to entities (#113757)
This commit is contained in:
parent
51b8ffc69d
commit
e20cc4f8b9
@ -165,6 +165,7 @@ def websocket_get_entities(
|
||||
vol.Optional("categories"): cv.schema_with_slug_keys(vol.Any(str, None)),
|
||||
vol.Optional("device_class"): vol.Any(str, None),
|
||||
vol.Optional("icon"): vol.Any(str, None),
|
||||
vol.Optional("labels"): [str],
|
||||
vol.Optional("name"): vol.Any(str, None),
|
||||
vol.Optional("new_entity_id"): str,
|
||||
# We only allow setting disabled_by user via API.
|
||||
@ -224,6 +225,10 @@ def websocket_update_entity(
|
||||
# Convert aliases to a set
|
||||
changes["aliases"] = set(msg["aliases"])
|
||||
|
||||
if "labels" in msg:
|
||||
# Convert labels to a set
|
||||
changes["labels"] = set(msg["labels"])
|
||||
|
||||
if "disabled_by" in msg and msg["disabled_by"] is None:
|
||||
# Don't allow enabling an entity of a disabled device
|
||||
if entity_entry.device_id:
|
||||
|
@ -532,6 +532,7 @@ async def test_update_entity(
|
||||
"device_class": "custom_device_class",
|
||||
"hidden_by": "user", # We exchange strings over the WS API, not enums
|
||||
"icon": "icon:after update",
|
||||
"labels": ["label1", "label2"],
|
||||
"name": "after update",
|
||||
}
|
||||
)
|
||||
@ -554,7 +555,7 @@ async def test_update_entity(
|
||||
"hidden_by": "user", # We exchange strings over the WS API, not enums
|
||||
"icon": "icon:after update",
|
||||
"id": ANY,
|
||||
"labels": [],
|
||||
"labels": unordered(["label1", "label2"]),
|
||||
"name": "after update",
|
||||
"options": {},
|
||||
"original_device_class": None,
|
||||
@ -628,7 +629,7 @@ async def test_update_entity(
|
||||
"hidden_by": "user", # We exchange strings over the WS API, not enums
|
||||
"icon": "icon:after update",
|
||||
"id": ANY,
|
||||
"labels": [],
|
||||
"labels": unordered(["label1", "label2"]),
|
||||
"name": "after update",
|
||||
"options": {},
|
||||
"original_device_class": None,
|
||||
@ -669,7 +670,7 @@ async def test_update_entity(
|
||||
"hidden_by": "user", # We exchange strings over the WS API, not enums
|
||||
"icon": "icon:after update",
|
||||
"id": ANY,
|
||||
"labels": [],
|
||||
"labels": unordered(["label1", "label2"]),
|
||||
"name": "after update",
|
||||
"options": {"sensor": {"unit_of_measurement": "beard_second"}},
|
||||
"original_device_class": None,
|
||||
@ -709,7 +710,7 @@ async def test_update_entity(
|
||||
"hidden_by": "user", # We exchange strings over the WS API, not enums
|
||||
"icon": "icon:after update",
|
||||
"id": ANY,
|
||||
"labels": [],
|
||||
"labels": unordered(["label1", "label2"]),
|
||||
"name": "after update",
|
||||
"options": {"sensor": {"unit_of_measurement": "beard_second"}},
|
||||
"original_device_class": None,
|
||||
@ -749,7 +750,7 @@ async def test_update_entity(
|
||||
"hidden_by": "user", # We exchange strings over the WS API, not enums
|
||||
"icon": "icon:after update",
|
||||
"id": ANY,
|
||||
"labels": [],
|
||||
"labels": unordered(["label1", "label2"]),
|
||||
"name": "after update",
|
||||
"options": {"sensor": {"unit_of_measurement": "beard_second"}},
|
||||
"original_device_class": None,
|
||||
@ -789,7 +790,7 @@ async def test_update_entity(
|
||||
"hidden_by": "user", # We exchange strings over the WS API, not enums
|
||||
"icon": "icon:after update",
|
||||
"id": ANY,
|
||||
"labels": [],
|
||||
"labels": unordered(["label1", "label2"]),
|
||||
"name": "after update",
|
||||
"options": {"sensor": {"unit_of_measurement": "beard_second"}},
|
||||
"original_device_class": None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user