Skip to content

Commit

Permalink
Improved error handling, added devices (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codechimp committed Dec 27, 2023
1 parent b322584 commit 01f3b19
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions custom_components/battery_notes/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand Down
20 changes: 13 additions & 7 deletions custom_components/battery_notes/data/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1394,4 +1400,4 @@
"battery_quantity": 2
}
]
}
}
2 changes: 1 addition & 1 deletion custom_components/battery_notes/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 01f3b19

Please sign in to comment.