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

Can't send commands to the mower #115480

Open
gimmel opened this issue Apr 12, 2024 · 25 comments
Open

Can't send commands to the mower #115480

gimmel opened this issue Apr 12, 2024 · 25 comments

Comments

@gimmel
Copy link

gimmel commented Apr 12, 2024

The problem

I used the Husqvarna HACS integration before and switched to the core implementation now.

I can see all sensors and diagnose data, but I can’t start and stop the mower. That makes it quite unusable for me. After pressing „Mähen beginnen“ (don’t know the english original text, „Start mowing“ perhaps) after some time I get an overlay with „Fehler beim Aufrufen des Diensts lawn_mower/start_mowing. Command couldn't be sent to the command queue: Error from API: 404: Not Found“ Doesn't matter if I use the integration UI or the services.

I already deleted the old app on Husqvarna developer page, generated a new one, deleted the integration from Homeassistant and added it again, nothing helps.

What version of Home Assistant Core has the issue?

core-2024.4.3

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

https://www.home-assistant.io/integrations/husqvarna_automower

Diagnostics information

The error log says this:

2024-04-12 17:28:43.441 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140480677314880] Command couldn't be sent to the command queue: Error from API: 404: Not Found
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/23277a77-6145-449c-aaf1-4eb11e64561d/actions')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/husqvarna_automower/lawn_mower.py", line 86, in async_start_mowing
    await self.coordinator.api.resume_schedule(self.mower_id)
  File "/usr/local/lib/python3.12/site-packages/aioautomower/session.py", line 164, in resume_schedule
    await self.auth.post_json(url, json=body)
  File "/usr/local/lib/python3.12/site-packages/aioautomower/auth.py", line 93, in post_json
    resp = await self.post(url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioautomower/auth.py", line 89, in post
    return await AbstractAuth._raise_for_status(resp)
           ^^^^^^^^^^^^^^^^^^^a^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioautomower/auth.py", line 157, in _raise_for_status
    raise ApiException(": ".join(detail)) from err
aioautomower.exceptions.ApiException: Error from API: 404: Not Found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 971, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/husqvarna_automower/lawn_mower.py", line 88, in async_start_mowing
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Command couldn't be sent to the command queue: Error from API: 404: Not Found

And I have noticed that the schedule button often jumps back to on automatically after setting it to off. I found this in the log, without pressing the schedule button at all. Because this is the reason?

2024-04-12 17:28:36.795 DEBUG (MainThread) [aioautomower.auth] response={'data': {'type': 'control', 'id': '73f3239a-47a6-46ee-8f61-01cb2c737256'}}
2024-04-12 17:30:58.368 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers/23277a77-6145-449c-aaf1-4eb11e64561d/actions None
2024-04-12 17:30:58.368 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ResumeSchedule'}}
2024-04-12 17:31:08.921 DEBUG (MainThread) [aioautomower.auth] response={'data': {'type': 'control', 'id': 'de561aac-e4c6-4070-bfe4-8721ea63bfaa'}}
2024-04-12 17:31:22.392 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers/23277a77-6145-449c-aaf1-4eb11e64561d/actions None
2024-04-12 17:31:22.392 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ResumeSchedule'}}
2024-04-12 17:31:31.354 DEBUG (MainThread) [aioautomower.auth] response={'data': {'type': 'control', 'id': 'e897d269-5be4-40b9-8e69-68d40e571613'}}
2024-04-12 17:31:37.668 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers/23277a77-6145-449c-aaf1-4eb11e64561d/actions None
2024-04-12 17:31:37.668 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ParkUntilNextSchedule'}}
2024-04-12 17:31:48.020 DEBUG (MainThread) [aioautomower.auth] response={'data': {'type': 'control', 'id': '4ea33eae-b61d-44a5-a3e7-36fc5faee152'}}
2024-04-12 17:31:54.085 DEBUG (MainThread) [aioautomower.auth] request[post]=https://api.amc.husqvarna.dev/v1/mowers/23277a77-6145-449c-aaf1-4eb11e64561d/actions None
2024-04-12 17:31:54.085 DEBUG (MainThread) [aioautomower.auth] request[post json]={'data': {'type': 'ResumeSchedule'}}
2024-04-12 17:32:02.992 DEBUG (MainThread) [aioautomower.auth] response={'data': {'type': 'control', 'id': '7d4cd734-2dd6-43b0-b647-57d180b7852b'}}

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)

@gimmel
Copy link
Author

gimmel commented Apr 30, 2024

Is it possible to install the old HACS version again?

@Thomas55555
Copy link
Contributor

Yes, that's possible, but we don't give support for custom components and we not recommend them.

To your bugs:
The flipping switch should be gone in ha 2024.5.0. But there shouldn't be commands send automatically.
Can you try again after upgrading to ha 2024.5.0 (after released) and send the debug log including the error message, if it happens again?

@Thomas55555
Copy link
Contributor

Also the device and config entry diagnostics would be helpful.

@JohKa
Copy link

JohKa commented May 2, 2024

As mentioned in #116280 the flipping problem still exists in 2024.5.0 but I'm able now to send commands like setting the light.

@gimmel
Copy link
Author

gimmel commented May 3, 2024

Thanks Thomas, I updated HA to version 2024.5.0 now, but I still can’t start the mower. If I press „Start mowing“, nothing happens at first, but then the schedule button activates automatically and some time later I get „Fehler beim Aufrufen des Diensts lawn_mower/start_mowing. Command couldn't be sent to the command queue: Error from API: 404: Not Found“.

Husqvarna.Integration.mp4

home-assistant_husqvarna_automower_2024-05-03T09-39-49.719Z.log

husqvarna_automower-4c3c56dee42c2ece46582f70a90186c5-Sprout-8aa689a45e73ba81655d5b2aab061b6a.json

@Thomas55555
Copy link
Contributor

For me the first part looks alright. If you click "Mähen beginnen", then the same command will be sent, like when you click "Zeitplan aktivieren". The command is called "ResumeSchedule", like mentions in the docs. This is because the API can't force the mower to just start, expect if we would force it to mow for a given duration.
As the entity model of HA and the API of Husqvarna don't fit 100%, it unfortunately like this.
Regarding the 404 error: I'm not sure, where this is coming from. Maybe, the config entry diagnostics could be helpful. You send the device diagnostics.

@jasoncross
Copy link

I'm still getting the issue where enable schedule turns itself back on right after turning it off. Running 2024.5.0. Logs attached.

home-assistant_husqvarna_automower_2024-05-03T13-47-48.367Z.log

@Thomas55555
Copy link
Contributor

I'm still getting the issue where enable schedule turns itself back on right after turning it off. Running 2024.5.0. Logs attached.

home-assistant_husqvarna_automower_2024-05-03T13-47-48.367Z.log

But as I can see in the logs, the mower received the command ParkUntilFurtherNotice and then started to go home. After the mower went home, was the switch in the right position?

@jasoncross
Copy link

Maybe it would help to understand better what the Enable Schedule switch is equivalent to with the Automower? Is it Parked? When flipped do I also need to tell it to return to dock? If flipped and returning to dock and I want to cancel, do I just flip it again or need to tell it to start mowing too?

@gimmel
Copy link
Author

gimmel commented May 4, 2024

I think we have a big misunderstanding here. I thought the service "lawn_mower.start_moving" would start the mowing process. But apparently the Husqvarna mower can only follow the schedule and the integration can only switch the schedule on and off. Could it be that the play and pause buttons only switch on and off the schedule? So perhaps the integration works as expected and my expectations are wrong?

In the Husqvarna app, I press the play button and then tap "Schedule off - 3 hours" to start the mower directly. But it also took me a long time to understand Husqvarna's operating strategy in the app. Husqvarna has a strange usage strategy ;-)

@Thomas55555
Copy link
Contributor

So Here the explanation:
If you turn the schedule on, the command resume schedule is sent to the mower. It's the same command like you send with the start button. After turning this on the switch should flip instantly and stay there
If you turn the schedule off, the command park until further notice is sent. If the mower is already in the dock, than the switch should instantly flip to off and stay there.
If the mower is not in the dock, and you turn the schedule off, then the switch should also go off instantly, but flips back to on after a while. When the mower arrived in the dock, then the switch should go off again.
Is the problem with sending commands not possible finally solved?

@davidm-glitch
Copy link

Does that mean, that there is no way to start the mower manually from HA?

@gimmel
Copy link
Author

gimmel commented May 10, 2024

Is the problem with sending commands not possible finally solved?

That’s hard to say, because we don’t exactly know what the intended functionality is.
If I understand you right, the button „Start mowing“ does not start mowing, but just activates the schedule? And all buttons (play, pause) have just the function to start and pause the schedule? Is that right?

@Thomas55555
Copy link
Contributor

'Start mowing' and the play button is the same. No idea, why HA makes two buttons there. Enable schedule is also the same.
Pause just pauses the mower. Example: mower is mowing and you press pause, than the mower makes a break.
If you click on the dock button, then the mower parks until the next schedule.

@gimmel
Copy link
Author

gimmel commented May 13, 2024

I think that is the main problem. People expect the mower to start mowing if they press „start mowing“. But what it does is „enable schedule“.

But there is an Husqvarna API command for „Start“. That should be used instead of „ResumeSchedule“.

Button Start Mowing/Play -> API Start
Button Pause -> API Pause
Button Dock -> API ParkUntilNextSchedule or ParkUntilFurtherNotice (depending on Enable Schedule)
Switch Enable Schedule -> API ParkUntilFurtherNotice/ResumeSchedule

That is the only way we can actively control the mower.

What "start moving" is doing now:
Husqvarna ResumeSchedule

What "start moving" should do:
Husqvarna Start

@Thomas55555
Copy link
Contributor

Thomas55555 commented May 13, 2024

But there is always a duration required for start. So if this time is over, the people wonder, why it stopped.

@Thomas55555
Copy link
Contributor

There is also another way, how you can actively control the mower: when you have a schedule enabled 24/7. And than say: Resume schedule, then the mower starts. And if you disable the schedule, the mower parks until further notice....

@gimmel
Copy link
Author

gimmel commented May 14, 2024

There is also another way, how you can actively control the mower: when you have a schedule enabled 24/7. And than say: Resume schedule, then the mower starts. And if you disable the schedule, the mower parks until further notice....

Yes, but who wants a workaround to make a new integration work like expected? Schedule and manual control are different things and should be treated as that. The mower documentation clearly says what the functions should do. It says "Start or resume a mowing task", not „Enable schedule“.

But there is always a duration required for start. So if this time is over, the people wonder, why it stopped.

You could define an input field for that or simply set the value to 24 hours.

@Thomas55555
Copy link
Contributor

You are right it's not 100% correct.
But for me it seems better to return the schedule. Maybe another user wants to start the mower for 25h or forever, than her would open an issue for that.
To be 100% correct, than the lawn mower entity should only have the pause button. The other commands have to be done over buttons and services.
Btw. I've opened a pull request for the star for command as a service. If everything works, then it will be in the next release.

@jasoncross
Copy link

My problem is that I can't get the mower to resume mowing.

I have an automation that parks the mower at its base when rain starts and resumes mowing 3 hours after rain ends.

When rain starts, I turn off the "Enable Schedule" switch. This sends it home.

When rain ends, I have tried both turning back on Enable Schedule as well as Starting the mower, but no matter what it stays parked until further notice

Logs attached.

home-assistant_husqvarna_automower_2024-05-14T16-51-23.360Z.log
.

@gimmel
Copy link
Author

gimmel commented May 15, 2024

You are right it's not 100% correct. But for me it seems better to return the schedule.

Come on, your integration is now an official part of Homeassistant and uses the internal mower implementation. Imagine if every integration used the light implementation differently, or switches or media players. You would have to search for a long time to find out how this one integration works. That's why there are global integrations like mowers and lights: you only control one device abstraction and this then controls the device via an integration. This is one of the many advantages of Homeassistant. For example, I can replace my mower with another model and everything continues to work as before. However, this does not work if each integration follows a different strategy.

To be 100% correct, than the lawn mower entity should only have the pause button.

No, the other way around: the mower abstraction has this buttons with a reason. You need them for automations, you need them to control the mower. If you just want to use the Husqvarna schedule, you don’t need a Homeassistant integration at all.

Maybe another user wants to start the mower for 25h or forever.

The play button should simply start the mower - without a time limit. That's what the dock button is made for. This can all be controlled wonderfully via automations. If a user wants to run the mower for 25 hours, his automation sends a play and 25 hours later a dock. Why not setting the Husqvarna API Start duration to 20 years? It’s an unsigned int64. You can set it even to 18,446,744,073,709,551,615 minutes. These are 35 Trillion years. The sun will have gone out by then. And Husqvarna, too. 😉

@gimmel
Copy link
Author

gimmel commented May 20, 2024

When rain starts, I turn off the "Enable Schedule" switch. This sends it home.

When rain ends, I have tried both turning back on Enable Schedule as well as Starting the mower, but no matter what it stays parked until further notice

I think your schedule is over after 3 hours. This integration can’t start your mower. It only enables and disables the schedule.

@coachdesign
Copy link

My problem is that I can't get the mower to resume mowing.

I have an automation that parks the mower at its base when rain starts and resumes mowing 3 hours after rain ends.

When rain starts, I turn off the "Enable Schedule" switch. This sends it home.

When rain ends, I have tried both turning back on Enable Schedule as well as Starting the mower, but no matter what it stays parked until further notice

Logs attached.

home-assistant_husqvarna_automower_2024-05-14T16-51-23.360Z.log .

with the old unofficial version, I had about the same automaticity, depending on how much it rained I sent a "return to base" command for N minutes.
with this new official version it is no longer possible to do so.

I think your schedule is over after 3 hours. This integration can’t start your mower. It only enables and disables the schedule.

logically I also tried to set "disable schedule" and after N hours "enable schedule", but it doesn't work, how can you reproduce this automation?

@jasoncross
Copy link

When rain starts, I turn off the "Enable Schedule" switch. This sends it home.
When rain ends, I have tried both turning back on Enable Schedule as well as Starting the mower, but no matter what it stays parked until further notice

I think your schedule is over after 3 hours. This integration can’t start your mower. It only enables and disables the schedule.

My schedule in the app is set to 24x7 effectively.

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

6 participants