From b968b53e38b68c7a7f1959ab9fc539f3bf225e46 Mon Sep 17 00:00:00 2001 From: croghostrider Date: Wed, 4 Sep 2019 02:33:48 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20Emulated=20Hue=20AttributeError:=20'NoneT?= =?UTF-8?q?ype'=20object=20has=20no=20attribute=20'=E2=80=A6=20(#26018)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix Emulated Hue AttributeError: 'NoneType' object has no attribute 'lower' * Fix debug * Update error message --- homeassistant/components/emulated_hue/hue_api.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index 5e1c72618b6..5d08af6c5ee 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -197,11 +197,19 @@ class HueOneLightStateView(HomeAssistantView): return self.json_message("only local IPs allowed", HTTP_BAD_REQUEST) hass = request.app["hass"] - entity_id = self.config.number_to_entity_id(entity_id) - entity = hass.states.get(entity_id) + hass_entity_id = self.config.number_to_entity_id(entity_id) + + if hass_entity_id is None: + _LOGGER.error( + "Unknown entity number: %s not found in emulated_hue_ids.json", + entity_id, + ) + return web.Response(text="Entity not found", status=404) + + entity = hass.states.get(hass_entity_id) if entity is None: - _LOGGER.error("Entity not found: %s", entity_id) + _LOGGER.error("Entity not found: %s", hass_entity_id) return web.Response(text="Entity not found", status=404) if not self.config.is_entity_exposed(entity):