1 Commits

Author SHA1 Message Date
RyanClark123
ad699b47d7 Added reauth flow, much better error handling on setup
### Feature
* Now supports reauthentication if credentials have expired/no longer work
* Better error handling when configuring integration, will notify user of incorrect credentials

### Fix
* Removed Owlet specific constants, now using homeassistant generic constants
* On initialisation the integration would crash when trying to update the auth token, the integration would then have to be deleted and setup again
2023-05-12 16:58:50 +01:00
6 changed files with 29 additions and 28 deletions

1
.gitignore vendored
View File

@@ -152,4 +152,3 @@ cython_debug/
#.idea/ #.idea/
/custom_components/owlet.zip /custom_components/owlet.zip
custom_components/owlet/owlet.zip

View File

@@ -1,12 +1,6 @@
# Changelog # Changelog
<!--next-version-placeholder--> <!--next-version-placeholder-->
## 2023-05-1 (2023-05-15)
#### Feature
* Changed versioning to date based
### Fix
* Bumping to pyowletapi 2023.5.21 to fix issue with unawaited authentication call, should resolve issue with refreshing authentication ([`228d54b`](https://github.com/ryanbdclark/owlet/commit/228d54b6414e0b9171064254246d1f36c3af8f5b))
## v1.5.0 (2023-05-12) ## v1.5.0 (2023-05-12)
### Feature ### Feature

View File

@@ -1,6 +1,8 @@
# Owlet Custom Integration # Owlet Custom Integration
[![GitHub Release][releases-shield]][releases] [![GitHub Release][releases-shield]][releases]
![GitHub all releases][download-all]
![GitHub release (latest by RyanClark123)][download-latest]
[![GitHub Activity][commits-shield]][commits] [![GitHub Activity][commits-shield]][commits]
[![License][license-shield]][license] [![License][license-shield]][license]
@@ -14,7 +16,7 @@ If you have a smart sock 2 and would like to contribute then please do so.
## Installation ## Installation
1. Use [HACS](https://hacs.xyz/docs/setup/download), in `HACS > Integrations > Explore & Add Repositories` search for "Owlet". After adding this `https://github.com/ryanbdclark/owlet` as a custom repository. 1. Use [HACS](https://hacs.xyz/docs/setup/download), in `HACS > Integrations > Explore & Add Repositories` search for "Owlet". After adding this `https://github.com/RyanClark123/owlet` as a custom repository.
2. Restart Home Assistant. 2. Restart Home Assistant.
3. [![Add Integration][add-integration-badge]][add-integration] or in the HA UI go to "Settings" -> "Devices & Services" then click "+" and search for "Owlet Smart Sock". 3. [![Add Integration][add-integration-badge]][add-integration] or in the HA UI go to "Settings" -> "Devices & Services" then click "+" and search for "Owlet Smart Sock".
@@ -36,15 +38,17 @@ This integration provides the following entities:
--- ---
[commits-shield]: https://img.shields.io/github/commit-activity/w/ryanbdclark/owlet?style=for-the-badge [commits-shield]: https://img.shields.io/github/commit-activity/w/RyanClark123/owlet?style=for-the-badge
[commits]: https://github.com/ryanbdclark/owlet/commits/main [commits]: https://github.com/RyanClark123/owlet/commits/main
[hacs]: https://github.com/hacs/integration [hacs]: https://github.com/hacs/integration
[hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge
[license]: LICENSE [license]: LICENSE
[license-shield]: https://img.shields.io/github/license/ryanbdclark/owlet.svg?style=for-the-badge [license-shield]: https://img.shields.io/github/license/RyanClark123/owlet.svg?style=for-the-badge
[maintenance-shield]: https://img.shields.io/badge/maintainer-Ryan%20Clark%20%40ryanbdclark-blue.svg?style=for-the-badge [maintenance-shield]: https://img.shields.io/badge/maintainer-Ryan%20Clark%20%40RyanClark123-blue.svg?style=for-the-badge
[releases-shield]: https://img.shields.io/github/release/ryanbdclark/owlet.svg?style=for-the-badge [releases-shield]: https://img.shields.io/github/release/RyanClark123/owlet.svg?style=for-the-badge
[releases]: https://github.com/ryanbdclark/owlet/releases [releases]: https://github.com/RyanClark123/owlet/releases
[user_profile]: https://github.com/ryanbdclark [user_profile]: https://github.com/RyanClark123
[download-all]: https://img.shields.io/github/downloads/RyanClark123/Owlet/total?style=for-the-badge
[download-latest]: https://img.shields.io/github/downloads/RyanClark123/Owlet/latest/total?style=for-the-badge
[add-integration]: https://my.home-assistant.io/redirect/config_flow_start?domain=owlet [add-integration]: https://my.home-assistant.io/redirect/config_flow_start?domain=owlet
[add-integration-badge]: https://my.home-assistant.io/badges/config_flow_start.svg [add-integration-badge]: https://my.home-assistant.io/badges/config_flow_start.svg

View File

@@ -5,7 +5,7 @@ from datetime import timedelta
import logging import logging
from pyowletapi.sock import Sock from pyowletapi.sock import Sock
from pyowletapi.exceptions import OwletError, OwletConnectionError from pyowletapi.exceptions import OwletError
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@@ -49,5 +49,5 @@ class OwletCoordinator(DataUpdateCoordinator):
"""Fetch the data from the device.""" """Fetch the data from the device."""
try: try:
await self.sock.update_properties() await self.sock.update_properties()
except (OwletError, OwletConnectionError) as err: except OwletError as err:
raise UpdateFailed(err) from err raise UpdateFailed(err) from err

View File

@@ -2,7 +2,7 @@
"domain": "owlet", "domain": "owlet",
"name": "Owlet Smart Sock", "name": "Owlet Smart Sock",
"codeowners": [ "codeowners": [
"@ryanbdclark" "@RyanClark123"
], ],
"config_flow": true, "config_flow": true,
"dependencies": [], "dependencies": [],
@@ -10,7 +10,7 @@
"homekit": {}, "homekit": {},
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"requirements": [ "requirements": [
"pyowletapi==2023.5.21" "pyowletapi==2023.5.20"
], ],
"version":"2023.5.1" "version":"1.5.0"
} }

18
info.md
View File

@@ -1,6 +1,8 @@
# Owlet Custom Integration # Owlet Custom Integration
[![GitHub Release][releases-shield]][releases] [![GitHub Release][releases-shield]][releases]
![GitHub all releases][download-all]
![GitHub release (latest by RyanClark123)][download-latest]
[![GitHub Activity][commits-shield]][commits] [![GitHub Activity][commits-shield]][commits]
[![License][license-shield]][license] [![License][license-shield]][license]
@@ -25,15 +27,17 @@ If you have a smart sock 2 and would like to contribute then please do so.
--- ---
[commits-shield]: https://img.shields.io/github/commit-activity/w/ryanbdclark/owlet?style=for-the-badge [commits-shield]: https://img.shields.io/github/commit-activity/w/RyanClark123/owlet?style=for-the-badge
[commits]: https://github.com/ryanbdclark/owlet/commits/main [commits]: https://github.com/RyanClark123/owlet/commits/main
[hacs]: https://github.com/hacs/integration [hacs]: https://github.com/hacs/integration
[hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge
[license]: LICENSE [license]: LICENSE
[license-shield]: https://img.shields.io/github/license/ryanbdclark/owlet.svg?style=for-the-badge [license-shield]: https://img.shields.io/github/license/RyanClark123/owlet.svg?style=for-the-badge
[maintenance-shield]: https://img.shields.io/badge/maintainer-Ryan%20Clark%20%40ryanbdclark-blue.svg?style=for-the-badge [maintenance-shield]: https://img.shields.io/badge/maintainer-Ryan%20Clark%20%40RyanClark123-blue.svg?style=for-the-badge
[releases-shield]: https://img.shields.io/github/release/ryanbdclark/owlet.svg?style=for-the-badge [releases-shield]: https://img.shields.io/github/release/RyanClark123/owlet.svg?style=for-the-badge
[releases]: https://github.com/ryanbdclark/owlet/releases [releases]: https://github.com/RyanClark123/owlet/releases
[user_profile]: https://github.com/ryanbdclark [user_profile]: https://github.com/RyanClark123
[download-all]: https://img.shields.io/github/downloads/RyanClark123/Owlet/total?style=for-the-badge
[download-latest]: https://img.shields.io/github/downloads/RyanClark123/Owlet/latest/total?style=for-the-badge
[add-integration]: https://my.home-assistant.io/redirect/config_flow_start?domain=owlet [add-integration]: https://my.home-assistant.io/redirect/config_flow_start?domain=owlet
[add-integration-badge]: https://my.home-assistant.io/badges/config_flow_start.svg [add-integration-badge]: https://my.home-assistant.io/badges/config_flow_start.svg