Review comments

pull/19194/head
Erik 2018-12-12 16:30:42 +01:00
parent c7492b0feb
commit d03dfd985b
1 changed files with 3 additions and 4 deletions

View File

@ -1,7 +1,7 @@
"""HTTP views to interact with the entity registry.""" """HTTP views to interact with the entity registry."""
import voluptuous as vol import voluptuous as vol
from homeassistant.core import callback, split_entity_id from homeassistant.core import callback
from homeassistant.helpers.entity_registry import async_get_registry from homeassistant.helpers.entity_registry import async_get_registry
from homeassistant.components import websocket_api from homeassistant.components import websocket_api
from homeassistant.components.websocket_api.const import ERR_NOT_FOUND from homeassistant.components.websocket_api.const import ERR_NOT_FOUND
@ -106,10 +106,9 @@ 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 (msg['new_entity_id'] in hass.states.async_entity_ids( if hass.states.get(msg['new_entity_id']) is not None:
split_entity_id(msg['new_entity_id'])[0])):
connection.send_message(websocket_api.error_message( connection.send_message(websocket_api.error_message(
msg['id'], ERR_NOT_FOUND, 'Entity is already registered')) msg['id'], 'invalid_info', 'Entity is already registered'))
return return
try: try: