Entity Registry to store and restore name/icon (#31714)
* Entity Registry to store and restore name/icon * Update test_entity_registry.py * Add original name/icon to JSON result
This commit is contained in:
1 parent
ecd7ec385d
commit
51c35ab9a8
6 files changed
+84
-7
No files matched your search
@@ -68,6 +68,7 @@ async def websocket_get_entity(hass, connection, msg):
|
||||
vol.Required("entity_id"): cv.entity_id,
|
||||
# If passed in, we update value. Passing None will remove old value.
|
||||
vol.Optional("name"): vol.Any(str, None),
|
||||
vol.Optional("icon"): vol.Any(str, None),
|
||||
vol.Optional("new_entity_id"): str,
|
||||
# We only allow setting disabled_by user via API.
|
||||
vol.Optional("disabled_by"): vol.Any("user", None),
|
||||
@@ -88,11 +89,9 @@ async def websocket_update_entity(hass, connection, msg):
|
||||
|
||||
changes = {}
|
||||
|
||||
if "name" in msg:
|
||||
changes["name"] = msg["name"]
|
||||
|
||||
if "disabled_by" in msg:
|
||||
changes["disabled_by"] = msg["disabled_by"]
|
||||
for key in ("name", "icon", "disabled_by"):
|
||||
if key in msg:
|
||||
changes[key] = msg[key]
|
||||
|
||||
if "new_entity_id" in msg and msg["new_entity_id"] != msg["entity_id"]:
|
||||
changes["new_entity_id"] = msg["new_entity_id"]
|
||||
@@ -151,5 +150,8 @@ def _entry_dict(entry):
|
||||
"disabled_by": entry.disabled_by,
|
||||
"entity_id": entry.entity_id,
|
||||
"name": entry.name,
|
||||
"icon": entry.icon,
|
||||
"platform": entry.platform,
|
||||
"original_name": entry.original_name,
|
||||
"original_icon": entry.original_icon,
|
||||
}
|
||||
Reference in new issue
Block a user