From a7404e638d4e368d7b199b1d787dd565752da239 Mon Sep 17 00:00:00 2001 From: Ruixiong Wen Date: Thu, 10 Nov 2022 18:04:28 +0800 Subject: [PATCH] fix: the get group device response may not contain entities --- terncy/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/terncy/__init__.py b/terncy/__init__.py index fdc5e49..edc37ff 100644 --- a/terncy/__init__.py +++ b/terncy/__init__.py @@ -381,7 +381,7 @@ async def async_refresh_devices(hass: HomeAssistant, tern): devices = response["rsp"]["entities"] group_response = await tern.get_entities("devicegroup", True) - groups = group_response["rsp"]["entities"] + groups = group_response["rsp"].get("entities") pdata = tern.hass_platform_data @@ -398,9 +398,10 @@ async def async_refresh_devices(hass: HomeAssistant, tern): for dev in devices: await update_or_create_entity(dev, tern) - - for group in groups: - await update_or_create_entity(group, tern) + + if groups: + for group in groups: + await update_or_create_entity(group, tern) async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):