mirror of
https://github.com/home-assistant/core
synced 2024-09-03 08:14:07 +02:00
Change get_entity to return a extended entry, add inputs to de… (#32083)
* Change get_entity to return a extended entry + add inputs to default config For https://github.com/home-assistant/home-assistant-polymer/pull/4940 * Fix tests, simplify code, update to return extended Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
edfb967b10
commit
fcaabb3d33
@ -57,7 +57,9 @@ async def websocket_get_entity(hass, connection, msg):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
connection.send_message(websocket_api.result_message(msg["id"], _entry_dict(entry)))
|
connection.send_message(
|
||||||
|
websocket_api.result_message(msg["id"], _entry_ext_dict(entry))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@require_admin
|
@require_admin
|
||||||
@ -112,7 +114,7 @@ async def websocket_update_entity(hass, connection, msg):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
connection.send_message(
|
connection.send_message(
|
||||||
websocket_api.result_message(msg["id"], _entry_dict(entry))
|
websocket_api.result_message(msg["id"], _entry_ext_dict(entry))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -152,6 +154,15 @@ def _entry_dict(entry):
|
|||||||
"name": entry.name,
|
"name": entry.name,
|
||||||
"icon": entry.icon,
|
"icon": entry.icon,
|
||||||
"platform": entry.platform,
|
"platform": entry.platform,
|
||||||
"original_name": entry.original_name,
|
|
||||||
"original_icon": entry.original_icon,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _entry_ext_dict(entry):
|
||||||
|
"""Convert entry to API format."""
|
||||||
|
data = _entry_dict(entry)
|
||||||
|
data["original_name"] = entry.original_name
|
||||||
|
data["original_icon"] = entry.original_icon
|
||||||
|
data["unique_id"] = entry.unique_id
|
||||||
|
data["capabilities"] = entry.capabilities
|
||||||
|
return data
|
||||||
|
@ -19,7 +19,12 @@
|
|||||||
"system_health",
|
"system_health",
|
||||||
"updater",
|
"updater",
|
||||||
"zeroconf",
|
"zeroconf",
|
||||||
"zone"
|
"zone",
|
||||||
|
"input_boolean",
|
||||||
|
"input_datetime",
|
||||||
|
"input_text",
|
||||||
|
"input_number",
|
||||||
|
"input_select"
|
||||||
],
|
],
|
||||||
"codeowners": []
|
"codeowners": []
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,6 @@ async def test_list_entities(hass, client):
|
|||||||
"entity_id": "test_domain.name",
|
"entity_id": "test_domain.name",
|
||||||
"name": "Hello World",
|
"name": "Hello World",
|
||||||
"icon": None,
|
"icon": None,
|
||||||
"original_name": None,
|
|
||||||
"original_icon": None,
|
|
||||||
"platform": "test_platform",
|
"platform": "test_platform",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -53,8 +51,6 @@ async def test_list_entities(hass, client):
|
|||||||
"entity_id": "test_domain.no_name",
|
"entity_id": "test_domain.no_name",
|
||||||
"name": None,
|
"name": None,
|
||||||
"icon": None,
|
"icon": None,
|
||||||
"original_name": None,
|
|
||||||
"original_icon": None,
|
|
||||||
"platform": "test_platform",
|
"platform": "test_platform",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -94,6 +90,8 @@ async def test_get_entity(hass, client):
|
|||||||
"icon": None,
|
"icon": None,
|
||||||
"original_name": None,
|
"original_name": None,
|
||||||
"original_icon": None,
|
"original_icon": None,
|
||||||
|
"capabilities": None,
|
||||||
|
"unique_id": "1234",
|
||||||
}
|
}
|
||||||
|
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
@ -115,6 +113,8 @@ async def test_get_entity(hass, client):
|
|||||||
"icon": None,
|
"icon": None,
|
||||||
"original_name": None,
|
"original_name": None,
|
||||||
"original_icon": None,
|
"original_icon": None,
|
||||||
|
"capabilities": None,
|
||||||
|
"unique_id": "6789",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -165,6 +165,8 @@ async def test_update_entity(hass, client):
|
|||||||
"icon": "icon:after update",
|
"icon": "icon:after update",
|
||||||
"original_name": None,
|
"original_name": None,
|
||||||
"original_icon": None,
|
"original_icon": None,
|
||||||
|
"capabilities": None,
|
||||||
|
"unique_id": "1234",
|
||||||
}
|
}
|
||||||
|
|
||||||
state = hass.states.get("test_domain.world")
|
state = hass.states.get("test_domain.world")
|
||||||
@ -208,6 +210,8 @@ async def test_update_entity(hass, client):
|
|||||||
"icon": "icon:after update",
|
"icon": "icon:after update",
|
||||||
"original_name": None,
|
"original_name": None,
|
||||||
"original_icon": None,
|
"original_icon": None,
|
||||||
|
"capabilities": None,
|
||||||
|
"unique_id": "1234",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -254,6 +258,8 @@ async def test_update_entity_no_changes(hass, client):
|
|||||||
"icon": None,
|
"icon": None,
|
||||||
"original_name": None,
|
"original_name": None,
|
||||||
"original_icon": None,
|
"original_icon": None,
|
||||||
|
"capabilities": None,
|
||||||
|
"unique_id": "1234",
|
||||||
}
|
}
|
||||||
|
|
||||||
state = hass.states.get("test_domain.world")
|
state = hass.states.get("test_domain.world")
|
||||||
@ -329,6 +335,8 @@ async def test_update_entity_id(hass, client):
|
|||||||
"icon": None,
|
"icon": None,
|
||||||
"original_name": None,
|
"original_name": None,
|
||||||
"original_icon": None,
|
"original_icon": None,
|
||||||
|
"capabilities": None,
|
||||||
|
"unique_id": "1234",
|
||||||
}
|
}
|
||||||
|
|
||||||
assert hass.states.get("test_domain.world") is None
|
assert hass.states.get("test_domain.world") is None
|
||||||
|
Loading…
Reference in New Issue
Block a user