From 01f3b19b82412965fba9cff79eac774287f5042e Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Wed, 27 Dec 2023 09:00:01 +0000 Subject: [PATCH] Improved error handling, added devices (#156) --- README.md | 5 +---- .../battery_notes/config_flow.py | 14 ++++++------- .../battery_notes/data/library.json | 20 ++++++++++++------- custom_components/battery_notes/manifest.json | 2 +- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 484e095b..82a654d5 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,13 @@ Platform | Name | Description Or Search for `Battery Notes` in HACS and install it under the "Integrations" category. - -Restart Home Assistant - **Important** Add the following entry to your `configuration.yaml` ``` battery_notes: ``` -Restart Home Assistant a final time +Restart Home Assistant In the HA UI go to Settings -> Integrations click "+" and search for "Battery Notes" ### Manual Installation diff --git a/custom_components/battery_notes/config_flow.py b/custom_components/battery_notes/config_flow.py index 0b570bd0..b57f7990 100644 --- a/custom_components/battery_notes/config_flow.py +++ b/custom_components/battery_notes/config_flow.py @@ -110,9 +110,9 @@ async def async_step_user( device_id = user_input[CONF_DEVICE_ID] - coordinator = self.hass.data[DOMAIN][DATA_UPDATE_COORDINATOR] - - await coordinator.async_refresh() + if DOMAIN in self.hass.data: + 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) @@ -137,12 +137,12 @@ async def async_step_user( return await self.async_step_battery() - domain_config = self.hass.data[DOMAIN][DOMAIN_CONFIG] - schema = DEVICE_SCHEMA # If show_all_devices = is specified and true, don't filter - if domain_config.get(CONF_SHOW_ALL_DEVICES, False): - schema = DEVICE_SCHEMA_ALL + 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 return self.async_show_form( step_id="user", diff --git a/custom_components/battery_notes/data/library.json b/custom_components/battery_notes/data/library.json index 5ca8967a..753651ca 100644 --- a/custom_components/battery_notes/data/library.json +++ b/custom_components/battery_notes/data/library.json @@ -313,12 +313,6 @@ "model": "KR1", "battery_type": "CR2" }, - { - "manufacturer": "Google", - "model": "Topaz-2.7", - "battery_type": "AA", - "battery_quantity": 3 - }, { "manufacturer": "Govee", "model": "H5101/H5102/H5177", @@ -458,6 +452,12 @@ "battery_type": "AA", "battery_quantity": 4 }, + { + "manufacturer": "Kwikset", + "model": "Kevo", + "battery_type": "AA", + "battery_quantity": 4 + }, { "manufacturer": "Kwikset", "model": "SMARTCODE_DEADBOLT_10T", @@ -664,6 +664,12 @@ "model": "Electra Washbasin Faucet", "battery_type": "2CR5" }, + { + "manufacturer": "Orbit BHyve", + "model": "HT25-0000", + "battery_type": "AA", + "battery_quantity": 2 + }, { "manufacturer": "ORVIBO", "model": "e70f96b3773a4c9283c6862dbafb6a99", @@ -1394,4 +1400,4 @@ "battery_quantity": 2 } ] -} +} \ No newline at end of file diff --git a/custom_components/battery_notes/manifest.json b/custom_components/battery_notes/manifest.json index f8840c8f..bac13292 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.0" + "version": "1.3.1" } \ No newline at end of file