core icon indicating copy to clipboard operation
core copied to clipboard

Enable schedule cannot be turned off

Open mgoebel-gdit opened this issue 10 months ago β€’ 19 comments

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

mgoebel-gdit avatar Apr 27 '24 06:04 mgoebel-gdit

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)

home-assistant[bot] avatar Apr 27 '24 06:04 home-assistant[bot]

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

Thomas55555 avatar Apr 27 '24 20:04 Thomas55555

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

jasoncross avatar Apr 27 '24 20:04 jasoncross

https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging

Thomas55555 avatar Apr 27 '24 21:04 Thomas55555

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

Thomas55555 avatar Apr 28 '24 11:04 Thomas55555

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.

jasoncross avatar Apr 28 '24 14:04 jasoncross

There is a bug which makes some of the data from the mower unusable. It was already solved here: https://github.com/home-assistant/core/pull/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.

Thomas55555 avatar Apr 28 '24 15:04 Thomas55555

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.

JohKa avatar May 01 '24 20:05 JohKa

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.

mlg9000 avatar May 02 '24 02:05 mlg9000

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.

Thomas55555 avatar May 02 '24 15:05 Thomas55555

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?

mlg9000 avatar May 05 '24 04:05 mlg9000

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/

Thomas55555 avatar May 06 '24 17:05 Thomas55555

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'
            }
        }
    );

MaiKaY avatar May 08 '24 16:05 MaiKaY

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?

Thomas55555 avatar May 08 '24 16:05 Thomas55555

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 πŸ€·β€β™‚οΈ

MaiKaY avatar May 09 '24 06:05 MaiKaY

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.

mija87 avatar May 09 '24 06:05 mija87

@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"

MaiKaY avatar May 09 '24 06:05 MaiKaY

@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'}}

mija87 avatar May 09 '24 07:05 mija87

@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?

Thomas55555 avatar May 09 '24 17:05 Thomas55555

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..

mija87 avatar May 10 '24 05:05 mija87

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

I am using the latest HA version and it is still not working. Every time I disable the timetable activation flag, it is set again to enable.

stravanti avatar Jul 01 '24 08:07 stravanti

What version is it?

Thomas55555 avatar Jul 01 '24 14:07 Thomas55555

My version: "home_assistant": { "installation_type": "Home Assistant OS", "version": "2024.6.4", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.12.2", "docker": true, "arch": "aarch64", "timezone": "Europe/Vienna", "os_name": "Linux", "os_version": "6.6.31-haos-raspi", "supervisor": "2024.06.2", "host_os": "Home Assistant OS 12.4", "docker_version": "26.1.4", "chassis": "embedded", "run_as_root": true

But to be honest, it might not be an issue. Actually I would like to run my mower only manually triggered. Never based on any timetable. I am not able to completely deactivate the timetable. I set it now to 0-24h for all days. then if the flag is set to true (enable timetable in HA) it should not be an issue. I have just seen that after activating the husquarna in HA, it starts on itΒ΄s own and this has to be avoided. I will monitor this.

stravanti avatar Jul 02 '24 09:07 stravanti

Im also on the latest version of HA, but also not working :(

mija87 avatar Jul 02 '24 16:07 mija87

The PR is not in this version. It's included from 2024.7.0 Try this version tomorrow and give feedback.

Thomas55555 avatar Jul 02 '24 17:07 Thomas55555