mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Improve check for duplicated entity_id (#19194)
* Fail if new entity_id is in hass.states * Move check to websocket * Review comments
This commit is contained in:
commit
eada1a184c
@ -88,7 +88,7 @@ async def websocket_get_entity(hass, connection, msg):
|
|||||||
|
|
||||||
@async_response
|
@async_response
|
||||||
async def websocket_update_entity(hass, connection, msg):
|
async def websocket_update_entity(hass, connection, msg):
|
||||||
"""Handle get camera thumbnail websocket command.
|
"""Handle update entity websocket command.
|
||||||
|
|
||||||
Async friendly.
|
Async friendly.
|
||||||
"""
|
"""
|
||||||
@ -106,6 +106,10 @@ async def websocket_update_entity(hass, connection, msg):
|
|||||||
|
|
||||||
if 'new_entity_id' in msg:
|
if 'new_entity_id' in msg:
|
||||||
changes['new_entity_id'] = msg['new_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(
|
||||||
|
msg['id'], 'invalid_info', 'Entity is already registered'))
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if changes:
|
if changes:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user