Add friendly name to devices in the device registry (#21318)

* add friendly name to devices in the device registry

* switch to name_by_user

* review comments
This commit is contained in:
David F. Mulcahey authored and Paulus Schoutsen committed 2019-02-26 12:20:16 -08:00
1 parent a34524febe
commit c4400be62a
4 files changed
+34 -10

No files matched your search

@@ -19,6 +19,7 @@ SCHEMA_WS_UPDATE = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend({
vol.Required('type'): WS_TYPE_UPDATE,
vol.Required('device_id'): str,
vol.Optional('area_id'): vol.Any(str, None),
vol.Optional('name_by_user'): vol.Any(str, None),
})
@@ -49,11 +50,13 @@ async def websocket_update_device(hass, connection, msg):
"""Handle update area websocket command."""
registry = await async_get_registry(hass)
entry = registry.async_update_device(
msg['device_id'], area_id=msg['area_id'])
msg.pop('type')
msg_id = msg.pop('id')
entry = registry.async_update_device(**msg)
connection.send_message(websocket_api.result_message(
msg['id'], _entry_dict(entry)
msg_id, _entry_dict(entry)
))
@@ -70,4 +73,5 @@ def _entry_dict(entry):
'id': entry.id,
'hub_device_id': entry.hub_device_id,
'area_id': entry.area_id,
'name_by_user': entry.name_by_user,
}