Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #115 from simontegelid/token_callback
Browse files Browse the repository at this point in the history
Store token to config entry on update
  • Loading branch information
Thomas55555 authored Oct 14, 2021
2 parents aaed486 + 7ce007f commit c1c0900
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions custom_components/husqvarna_automower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
access_token = entry.data.get(CONF_TOKEN)

session = aioautomower.AutomowerSession(api_key, access_token)
session.register_token_callback(
lambda token: hass.config_entries.async_update_entry(
entry,
data={
CONF_TOKEN: token,
},
)
)

try:
await session.connect()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/husqvarna_automower/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@Thomas55555"
],
"requirements": [
"aioautomower==2021.10.2"
"aioautomower==2021.10.3"
],
"iot_class": "cloud_push",
"version": "0.0.0"
Expand Down

0 comments on commit c1c0900

Please sign in to comment.