Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable schedule cannot be turned off #116280

Open
mgoebel-gdit opened this issue Apr 27, 2024 · 20 comments
Open

Enable schedule cannot be turned off #116280

mgoebel-gdit opened this issue Apr 27, 2024 · 20 comments

Comments

@mgoebel-gdit
Copy link

The problem

It's not possible to disable the schedule and park the mower indefinitely. When you attempt the disable the schedule it simply turns itself back on and has no impact on the mower. This makes this integration useless for any automations, like telling the mower to go park itself until the rain stops for example.

Also, now that this integration has been moved to core it now has some major regressions in terms of overall functionality and and intuitive design. This switch should simply say "park the mower until further notice" rather than disable the schedule. It would be nice if you could adjust the schedule separately, provided the API supports this. As it stands now you can't even see the schedule.

What version of Home Assistant Core has the issue?

core-2024.4.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

husqvarna_automower

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

Hey there @Thomas55555, mind taking a look at this issue as it has been labeled with an integration (husqvarna_automower) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of husqvarna_automower can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign husqvarna_automower Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


husqvarna_automower documentation
husqvarna_automower source
(message by IssueLinks)

@Thomas55555
Copy link
Contributor

The switch should work. Can you provide some debug logs?

@jasoncross
Copy link

I have the same issue. What do I need to do to enable and provide debug logs for this device?

@Thomas55555
Copy link
Contributor

@Thomas55555
Copy link
Contributor

@home-assistant add-label needs-more-information

@jasoncross
Copy link

home-assistant_husqvarna_automower_2024-04-28T14-10-18.174Z.log

So this morning, it's showing the "Enable Schedule" flag as OFF (even though the mower is running on its schedule right now), and when I try to enable, it flips back to off. Did this a few times while in debugging mode. Logs above.

@Thomas55555
Copy link
Contributor

There is a bug which makes some of the data from the mower unusable. It was already solved here:
#114500
I'm pretty sure, that it is related to that. The bug is solved in HA > 2024.5.0b0.
It would be better, if we test it with the new version again. Please let me know, when you upgraded HA, if the problem still exists.

@JohKa
Copy link

JohKa commented May 1, 2024

the problem still exists in Version 2024.5.0.
I can disable the scheduling but I'm not able to enable it in HA again. the switch comes back true after some seconds but in the Husqvarna App the schedule is still disabled. this won't change if I press the "enable schedule" again.

@mlg9000
Copy link

mlg9000 commented May 2, 2024

This still isn't working properly. With 2024.5.0 if I turn the schedule off while the mower is running I get the following in the logs:

2024-05-01 16:57:36.830 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers//actions None
2024-05-01 16:57:36.830 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ParkUntilFurtherNotice'}}
2024-05-01 16:57:39.418 DEBUG (MainThread) [aioautomower.auth] response={'data': {'type': 'control', 'id': ''}}

The mower does go park itself indefinitely but the schedule flips itself back on in the meantime.

If I reload the integration the status updates to the correct state.

Turning the schedule back on there is the same issue. The mower is enabled but the schedule flips itself off again until a reload.

If I don't reload it eventually polls the API and gets the correct value but it seems to take almost 10 minutes in some cases to do that. In the meantime I see a half dozen 403 errors:

2024-05-01 17:06:37.111 DEBUG (MainThread) [homeassistant.components.husqvarna_automower.coordinator] Failed to connect to websocket. Trying to reconnect: 403, message='Invalid response status', url=URL('wss://ws.openapi.husqvarna.dev/v1')

The switch should behave like a switch and stay on/off when toggled and the confirmation response from the API is received. If the state changes during an API poll.

@Thomas55555
Copy link
Contributor

ls the API and gets the correct value but it seems to take almost 10 minutes in some cases to do that. In the meantime I see a half dozen 403 errors:

Can you share your config entry diagnostics. It looks like you your websocket connections is not working.

@mlg9000
Copy link

mlg9000 commented May 5, 2024

Can you share your config entry diagnostics. It looks like you your websocket connections is not working.

"integration_manifest": {
"domain": "husqvarna_automower",
"name": "Husqvarna Automower",
"codeowners": [
"@Thomas55555"
],
"config_flow": true,
"dependencies": [
"application_credentials"
],
"documentation": "https://www.home-assistant.io/integrations/husqvarna_automower",
"iot_class": "cloud_push",
"loggers": [
"aioautomower"
],
"requirements": [
"aioautomower==2024.4.3"
],
"is_built_in": true
},
"data": {
"entry_id": "REDACTED",
"version": 1,
"minor_version": 1,
"domain": "husqvarna_automower",
"title": "Husqvarna Automower of REDACTED",
"data": {
"auth_implementation": "husqvarna_automower_REDACTED",
"token": {
"access_token": "REDACTED",
"scope": "iam:read",
"expires_in": 86399,
"refresh_token": "REDACTED",
"provider": "husqvarna",
"user_id": "REDACTED",
"token_type": "Bearer",
"expires_at": 1714895939.6803994
}
},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"unique_id": "REDACTED",
"disabled_by": null
}

That's the relavent part for the husqvarna integration. I'm not sure how that helps with a 403 from Husqvarna?

The integration is working and the error doesn't seems to cause an issue. After watching some more it seems that polling is every 8 minutes. The 403 might be some sort of rate limit?

@Thomas55555
Copy link
Contributor

Can you share your config entry diagnostics. It looks like you your websocket connections is not working.

"integration_manifest": { "domain": "husqvarna_automower", "name": "Husqvarna Automower", "codeowners": [ "@Thomas55555" ], "config_flow": true, "dependencies": [ "application_credentials" ], "documentation": "https://www.home-assistant.io/integrations/husqvarna_automower", "iot_class": "cloud_push", "loggers": [ "aioautomower" ], "requirements": [ "aioautomower==2024.4.3" ], "is_built_in": true }, "data": { "entry_id": "REDACTED", "version": 1, "minor_version": 1, "domain": "husqvarna_automower", "title": "Husqvarna Automower of REDACTED", "data": { "auth_implementation": "husqvarna_automower_REDACTED", "token": { "access_token": "REDACTED", "scope": "iam:read", "expires_in": 86399, "refresh_token": "REDACTED", "provider": "husqvarna", "user_id": "REDACTED", "token_type": "Bearer", "expires_at": 1714895939.6803994 } }, "options": {}, "pref_disable_new_entities": false, "pref_disable_polling": false, "source": "user", "unique_id": "REDACTED", "disabled_by": null }

That's the relavent part for the husqvarna integration. I'm not sure how that helps with a 403 from Husqvarna?

The integration is working and the error doesn't seems to cause an issue. After watching some more it seems that polling is every 8 minutes. The 403 might be some sort of rate limit?

Is it possible, that you haven't added the Authentaication API and the Automower Connect API, like mentioned here?
https://www.home-assistant.io/integrations/husqvarna_automower/

@MaiKaY
Copy link

MaiKaY commented May 8, 2024

I got the same issue for using the switch. Everything else is working fine...

Part of my logs are attached:

  File "/usr/src/homeassistant/homeassistant/components/husqvarna_automower/switch.py", line 83, in async_turn_off
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Command couldn't be sent to the command queue: Error from API: 404: Not Found
2024-05-08 18:15:07.785 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers/xxx/actions None
2024-05-08 18:15:07.786 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ResumeSchedule'}}
2024-05-08 18:15:07.967 ERROR (MainThread) [homeassistant.components.script.xxx_start] xxx: Starte Zeitplan: Error executing script. Error for device at pos 1: Command couldn't be sent to the command queue: Error from API: 404: Not Found
2024-05-08 18:15:07.974 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547716739648] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aioautomower/auth.py", line 148, in _raise_for_status
    resp.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1070, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://api.amc.husqvarna.dev/v1/mowers/xxx/actions')

I am not good in reading python but my nodejs application works just fine, maybe the integration is missing some headers? 🤔

Example of my nodejs application:

    await axios.post(
        'https://api.amc.husqvarna.dev/v1/mowers/xxx/actions',
        {
            data: {
                type: 'ResumeSchedule'
            }
        },
        {
            headers: {
                'Authorization-Provider': 'husqvarna',
                'X-Api-Key': HUSQVARNA_API_KEY,
                Authorization: `Bearer ${accessToken}`,
                'Content-Type': 'application/vnd.api+json'
            }
        }
    );

@Thomas55555
Copy link
Contributor

I got the same issue for using the switch. Everything else is working fine...

Part of my logs are attached:

  File "/usr/src/homeassistant/homeassistant/components/husqvarna_automower/switch.py", line 83, in async_turn_off
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Command couldn't be sent to the command queue: Error from API: 404: Not Found
2024-05-08 18:15:07.785 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers/xxx/actions None
2024-05-08 18:15:07.786 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ResumeSchedule'}}
2024-05-08 18:15:07.967 ERROR (MainThread) [homeassistant.components.script.xxx_start] xxx: Starte Zeitplan: Error executing script. Error for device at pos 1: Command couldn't be sent to the command queue: Error from API: 404: Not Found
2024-05-08 18:15:07.974 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547716739648] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aioautomower/auth.py", line 148, in _raise_for_status
    resp.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1070, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://api.amc.husqvarna.dev/v1/mowers/xxx/actions')

I am not good in reading python but my nodejs application works just fine, maybe the integration is missing some headers? 🤔

Example of my nodejs application:

    await axios.post(
        'https://api.amc.husqvarna.dev/v1/mowers/xxx/actions',
        {
            data: {
                type: 'ResumeSchedule'
            }
        },
        {
            headers: {
                'Authorization-Provider': 'husqvarna',
                'X-Api-Key': HUSQVARNA_API_KEY,
                Authorization: `Bearer ${accessToken}`,
                'Content-Type': 'application/vnd.api+json'
            }
        }
    );

No, its exactly the same:
https://github.com/Thomas55555/aioautomower/blob/151411ca57a2833f562d6b5287d28bb3de1a33b9/src/aioautomower/auth.py#L137-L140
Did you use the same API-Key for nodejs?
Can you assure, that with the API-Key used in Home Assistant the "AutomowerConenct API" is connected to your account?

@MaiKaY
Copy link

MaiKaY commented May 9, 2024

its exactly the same

Thanks for pointing out that's exactly the same usage of headers 👍

Did you use the same API-Key for nodejs?

Yes

Can you assure, that with the API-Key used in Home Assistant the "AutomowerConenct API" is connected to your account?

Yes, I can assure the API-Key used in Home Assistant is connected to the "AutomowerConenct API" in my account.

⚠️ Today in the morning it works just fine without changing anything, maybe it was an outage of Husqvarna API 🤷‍♂️

@mija87
Copy link

mija87 commented May 9, 2024

its exactly the same

Thanks for pointing out that's exactly the same usage of headers 👍

Did you use the same API-Key for nodejs?

Yes

Can you assure, that with the API-Key used in Home Assistant the "AutomowerConenct API" is connected to your account?

Yes, I can assure the API-Key used in Home Assistant is connected to the "AutomowerConenct API" in my account.

⚠️ Today in the morning it works just fine without changing anything, maybe it was an outage of Husqvarna API 🤷‍♂️

I have exactly the same issue, but it still exists.

@MaiKaY
Copy link

MaiKaY commented May 9, 2024

@mija87

  • Did you update to latest Home Assistant version?
  • Did you enable logs to see whats going on under the hood?
  • Can you confirm that the credentials are setup correctly? click on "Settings" -> choose "Devices & Services" -> click on the three-dot-menu in top right corner -> choose "Application credentials" -> check the "OAuth client ID"

@mija87
Copy link

mija87 commented May 9, 2024

@mija87

  • Did you update to latest Home Assistant version?
    Yes
  • Did you enable logs to see whats going on under the hood?
    Check
  • Can you confirm that the credentials are setup correctly? click on "Settings" -> choose "Devices & Services" -> click on the three-dot-menu in top right corner -> choose "Application credentials" -> check the "OAuth client ID"
    Yes It is,.,

This is the log:
2024-05-09 09:37:30.814 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers/XX/actions None
2024-05-09 09:37:30.814 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ParkUntilFurtherNotice'}}
2024-05-09 09:37:33.313 DEBUG (MainThread) [aioautomower.auth] response={'data': {'type': 'control', 'id': 'XX'}}

@Thomas55555
Copy link
Contributor

@mija87

  • Did you update to latest Home Assistant version?
    Yes
  • Did you enable logs to see whats going on under the hood?
    Check
  • Can you confirm that the credentials are setup correctly? click on "Settings" -> choose "Devices & Services" -> click on the three-dot-menu in top right corner -> choose "Application credentials" -> check the "OAuth client ID"
    Yes It is,.,

This is the log: 2024-05-09 09:37:30.814 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers/XX/actions None 2024-05-09 09:37:30.814 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ParkUntilFurtherNotice'}} 2024-05-09 09:37:33.313 DEBUG (MainThread) [aioautomower.auth] response={'data': {'type': 'control', 'id': 'XX'}}

As there was a response at 2024-05-09 09:37:33.313, the command was accepted by the mower. Where is the problem?

@mija87
Copy link

mija87 commented May 10, 2024

The problem is that when I turn off the switch, the command is send, the mower goes back to "home" mode. But the switch turns back on after a few seconds. The switch itself does not give the right status of the schedule..

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

No branches or pull requests

8 participants