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

I have to reconfigure the integration after every home assistant restart #558

Open
chadmccune opened this issue Dec 9, 2023 · 15 comments
Open

Comments

@chadmccune
Copy link

Prerequirements
[ X] I have connected my mower(s) to the Automower Connect App
[ X] I have connected my Husqvanra developers account to the Authentication API
[ X] I have connected my Husqvarna developers account to the Automower Connect API

Describe the bug
Every time home assistant restarts, either due to an update or just me restarting it manually, I get a notification that I need to reconfigure the integration. It basically just makes me log back in and authorize it again.

Expected behavior
Would expect it to maintain its authentication token

Screenshots
image
image

Additional context
Add any other context about the problem here.

@Thomas55555
Copy link
Owner

Can you turn on debug logging, and restart HA?
Then please post your log.

@chadmccune
Copy link
Author

chadmccune commented Dec 9, 2023

Here is the log
home-assistant.log

@chadmccune
Copy link
Author

chadmccune commented Dec 9, 2023

Just to be clear, for whatever reason, this time it didn't do it....maybe I have to wait a bit in between restarts, I had just reconfigured it a few minutes before attempting again.

I've left debug logging enabled and will post log next time it happens

@chadmccune
Copy link
Author

I restarted again this morning and here are the relevant lines from the logs

2023-12-10 11:00:50.633 INFO (MainThread) [custom_components.husqvarna_automower]

husqvarna_automower
Version: 2023.10.0
This is a custom integration!
If you have any issues with this you need to open an issue here:
https://github.com/Thomas55555/husqvarna_automower

2023-12-10 11:00:50.634 DEBUG (MainThread) [aioautomower.session] Refresh access token
2023-12-10 11:00:51.585 DEBUG (MainThread) [aioautomower.rest] Resp.status refresh token: {'error': 'invalid_client', 'error_description': 'Client not found', 'error_code': 'client.not.found'}
2023-12-10 11:00:51.589 DEBUG (MainThread) [custom_components.husqvarna_automower] Exception in async_setup_entry: The token cannot be refreshed, respone from Husqvarna Automower API: {'error': 'invalid_client', 'error_description': 'Client not found', 'error_code': 'client.not.found'}
2023-12-10 11:00:51.591 DEBUG (MainThread) [custom_components.husqvarna_automower] Finished fetching husqvarna_automower data in 0.957 seconds (success: False)
2023-12-10 11:00:51.591 WARNING (MainThread) [homeassistant.config_entries] Config entry 'husqvarna_automower' for husqvarna_automower integration could not authenticate
2023-12-10 11:00:51.602 DEBUG (MainThread) [custom_components.husqvarna_automower.config_flow] USER INPUT NONE

@chadmccune
Copy link
Author

Lots of erros in the log after reauthenticating:

2023-12-10 11:09:19.973 DEBUG (MainThread) [custom_components.husqvarna_automower.config_flow] USER INPUT NONE
2023-12-10 11:09:21.066 DEBUG (MainThread) [custom_components.husqvarna_automower.config_flow] user_input: {}
2023-12-10 11:09:26.559 INFO (MainThread) [custom_components.husqvarna_automower.config_flow] Successfully authenticated
2023-12-10 11:09:26.936 DEBUG (MainThread) [aioautomower.rest] Response mower data: <ClientResponse(https://api.amc.husqvarna.dev/v1/mowers/) [401 Unauthorized]>
<CIMultiDictProxy('Content-Type': 'application/json', 'Content-Length': '26', 'Connection': 'keep-alive', 'Date': 'Sun, 10 Dec 2023 17:09:26 GMT', 'x-amzn-RequestId': '10dffe4c-83fe-4aef-818e-c61f066378d0', 'x-amzn-ErrorType': 'UnauthorizedException', 'x-amz-apigw-id': 'PvKPHGzZjoEEDmw=', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 3869c2955783c2ad4b60833fbd021c9a.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'DFW57-P2', 'X-Amz-Cf-Id': '6cpGrXVaeOTcjjomTaMptJ535--NlZlYZdwaJu1-5Jk4GZeFxUWXzQ==')>

2023-12-10 11:09:26.941 ERROR (MainThread) [aioautomower.rest] Response mower data: {'message': 'Unauthorized'}
2023-12-10 11:09:26.943 DEBUG (MainThread) [custom_components.husqvarna_automower] Finished fetching husqvarna_automower data in 0.383 seconds (success: True)
2023-12-10 11:09:26.944 DEBUG (MainThread) [aioautomower.session] LE: False
2023-12-10 11:09:26.944 DEBUG (MainThread) [aioautomower.session] token_monitor_task sleeping for 86338.61430191994 sec
2023-12-10 11:09:27.022 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up husqvarna_automower platform for binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/husqvarna_automower/binary_sensor.py", line 25, in async_setup_entry
for idx, ent in enumerate(coordinator.session.data["data"])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
2023-12-10 11:09:27.030 ERROR (MainThread) [homeassistant.components.image] Error while setting up husqvarna_automower platform for image
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/husqvarna_automower/image.py", line 51, in async_setup_entry
for idx, ent in enumerate(coordinator.session.data["data"]):
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
2023-12-10 11:09:27.035 ERROR (MainThread) [homeassistant.components.device_tracker] Error while setting up husqvarna_automower platform for device_tracker
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/husqvarna_automower/device_tracker.py", line 22, in async_setup_entry
for idx, ent in enumerate(coordinator.session.data["data"]):
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
2023-12-10 11:09:27.039 ERROR (MainThread) [homeassistant.components.number] Error while setting up husqvarna_automower platform for number
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/husqvarna_automower/number.py", line 28, in async_setup_entry
for idx, ent in enumerate(coordinator.session.data["data"])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
2023-12-10 11:09:27.043 ERROR (MainThread) [homeassistant.components.select] Error while setting up husqvarna_automower platform for select
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/husqvarna_automower/select.py", line 25, in async_setup_entry
for idx, ent in enumerate(coordinator.session.data["data"])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
2023-12-10 11:09:27.047 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up husqvarna_automower platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/husqvarna_automower/sensor.py", line 280, in async_setup_entry
for idx, ent in enumerate(coordinator.session.data["data"]):
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
2023-12-10 11:09:27.055 ERROR (MainThread) [homeassistant.components.vacuum] Error while setting up husqvarna_automower platform for vacuum
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/husqvarna_automower/vacuum.py", line 48, in async_setup_entry
for idx, ent in enumerate(coordinator.session.data["data"])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
2023-12-10 11:09:27.102 DEBUG (MainThread) [custom_components.husqvarna_automower.calendar] entry: <homeassistant.config_entries.ConfigEntry object at 0x7f026d2474c0>
2023-12-10 11:09:27.104 ERROR (MainThread) [homeassistant.components.calendar] Error while setting up husqvarna_automower platform for calendar
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/husqvarna_automower/calendar.py", line 33, in async_setup_entry
for idx, ent in enumerate(coordinator.session.data["data"])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
2023-12-10 11:09:27.509 DEBUG (MainThread) [aioautomower.session] Websocket (re)connected
2023-12-10 11:09:27.612 DEBUG (MainThread) [aioautomower.session] Websocket ready=True (id='PvKPMcqmDoECHyw=')

@Thomas55555
Copy link
Owner

Okay, I can't find directly a solution for that.
But I've completely reworked the library behind the integration. It's still in an early stage, and some features are missing. But if you like, you can test it. The token management is completely done by Home Assistant, so if that's the reason, it's solved. Also the Exceptions should be better, which could help to detect the problem.
If you want to try, download this branch:
https://github.com/Thomas55555/husqvarna_automower/tree/reworked-library
and copy the files like in the original version to your custom_component folder.
Maybe you need to delete the integration first.
Give me a feedback, if you've tested it.

@Thomas55555
Copy link
Owner

@chadmccune
Copy link
Author

I've downloaded it and will try restarting home assistant some time this weekend to see if it fixes it

@chadmccune
Copy link
Author

I haven't had any issues since doing this. Let me know when this is merged into the main branch so I can update through hacs.

Side note, are gps coordinates no longer available?

@kleinerhobbit
Copy link

Same here
I give your rework a try as well.

@valerix85
Copy link

You can use this download link: https://github.com/Thomas55555/husqvarna_automower/archive/refs/heads/reworked-library.zip

From my HA I have no problem =)

@Thomas55555
Copy link
Owner

I haven't had any issues since doing this. Let me know when this is merged into the main branch so I can update through hacs.

Side note, are gps coordinates no longer available?

GPS coordinates are not available yet. As a lot of other stuff. I have to implement everything new. I'm working on a official integration. Not sure if it's worth to do here first.

@bjornarfjelldal
Copy link

Experiencing the same re-auth problem, looking forward to either updated custom release or official integration :)

@Thomas55555
Copy link
Owner

If everything works, the official integration should ship in 2024.3
But not with all features, yet.

@CrallH
Copy link

CrallH commented Feb 27, 2024

got the same re-auth issue to. had it for at least a couple of monts. i thought it was because the robot is standing turned off in the garage. Nice to see that i was not the only one!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants