Fix not being able to update entities (#19344)

When editing an entity in the frontend dialog, pressing save causes a "save failed: Entity is already registered" error. This is because the frontend always sets `name` and `new_entity_id` in the websocket command even if they haven't been changed. This adds a check that the `new_entity_id` is actually different from `entity_id` before erroring that the `new_entity_id` is already registered.
This commit is contained in:
Glen Takahashi 2018-12-16 13:06:27 -05:00 committed by Charles Garwood
parent 5a295ad42b
commit b031ded671

View File

@ -104,7 +104,7 @@ async def websocket_update_entity(hass, connection, msg):
if 'name' in msg:
changes['name'] = msg['name']
if 'new_entity_id' in msg:
if 'new_entity_id' in msg and msg['new_entity_id'] != msg['entity_id']:
changes['new_entity_id'] = msg['new_entity_id']
if hass.states.get(msg['new_entity_id']) is not None:
connection.send_message(websocket_api.error_message(