From 33567672bb9a3a90b2c69274b390b6268aa5364d Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Wed, 27 Dec 2023 11:10:42 +0000 Subject: [PATCH] Improve error handling --- custom_components/battery_notes/config_flow.py | 12 +++++++----- custom_components/battery_notes/manifest.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/custom_components/battery_notes/config_flow.py b/custom_components/battery_notes/config_flow.py index b57f7990..063baf71 100644 --- a/custom_components/battery_notes/config_flow.py +++ b/custom_components/battery_notes/config_flow.py @@ -111,8 +111,9 @@ async def async_step_user( device_id = user_input[CONF_DEVICE_ID] if DOMAIN in self.hass.data: - coordinator = self.hass.data[DOMAIN][DATA_UPDATE_COORDINATOR] - await coordinator.async_refresh() + if DATA_UPDATE_COORDINATOR in self.hass.data[DOMAIN]: + coordinator = self.hass.data[DOMAIN][DATA_UPDATE_COORDINATOR] + await coordinator.async_refresh() device_registry = dr.async_get(self.hass) device_entry = device_registry.async_get(device_id) @@ -140,9 +141,10 @@ async def async_step_user( schema = DEVICE_SCHEMA # If show_all_devices = is specified and true, don't filter if DOMAIN in self.hass.data: - domain_config = self.hass.data[DOMAIN][DOMAIN_CONFIG] - if domain_config.get(CONF_SHOW_ALL_DEVICES, False): - schema = DEVICE_SCHEMA_ALL + if DOMAIN_CONFIG in self.hass.data[DOMAIN]: + domain_config = self.hass.data[DOMAIN][DOMAIN_CONFIG] + if domain_config.get(CONF_SHOW_ALL_DEVICES, False): + schema = DEVICE_SCHEMA_ALL return self.async_show_form( step_id="user", diff --git a/custom_components/battery_notes/manifest.json b/custom_components/battery_notes/manifest.json index bac13292..e819a4c4 100644 --- a/custom_components/battery_notes/manifest.json +++ b/custom_components/battery_notes/manifest.json @@ -9,5 +9,5 @@ "integration_type": "device", "iot_class": "calculated", "issue_tracker": "https://github.com/andrew-codechimp/ha-battery-notes/issues", - "version": "1.3.1" + "version": "1.3.2" } \ No newline at end of file