core icon indicating copy to clipboard operation
core copied to clipboard

Picnic todo list broken

Open joostlek opened this issue 2 years ago • 10 comments

The problem

Whenever I try to add a basic item to the todo list, it will fail.

cc @DCSBL

What version of Home Assistant Core has the issue?

2024.4.2

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

Picnic

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:1918
First occurred: 11:10:39 (1 occurrences)
Last logged: 11:10:39

websocket_api script: Error executing script. Error for call_service at pos 1: No product found or no product ID given

Additional information

No response

joostlek avatar Apr 10 '24 09:04 joostlek

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

Code owner commands

Code owners of picnic 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 picnic 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)


picnic documentation picnic source (message by IssueLinks)

home-assistant[bot] avatar Apr 10 '24 09:04 home-assistant[bot]

Calling the service directly triggers this error:

Logger: homeassistant.components.websocket_api.http.connection
Bron: components/picnic/services.py:72
integratie: Home Assistant WebSocket API ([documentatie](https://www.home-assistant.io/integrations/websocket_api), [problemen](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
Eerst voorgekomen: 12:05:25 (1 gebeurtenissen)
Laatst gelogd: 12:05:25

[281471527831872] Error handling message: Unknown error (unknown_error) Duco from 77.63.35.237 (Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2024.4 (io.robbie.HomeAssistant; build:2024.624; iOS 17.4.1) Mobile/HomeAssistant, like Safari)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 794, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1650, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 454, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 506, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 536, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 504, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 733, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 696, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2542, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2579, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/picnic/services.py", line 37, in async_add_product_service
    await handle_add_product(hass, api_client, call)
  File "/usr/src/homeassistant/homeassistant/components/picnic/services.py", line 72, in handle_add_product
    raise PicnicServiceException("No product found or no product ID given!")
homeassistant.components.picnic.services.PicnicServiceException: No product found or no product ID given!

DCSBL avatar Apr 10 '24 10:04 DCSBL

The app itself still works, so this maybe indicates the search API has been changed. This part was developed by @Corneyl, maybe you can take a quick look in this?

(I only implemented search into ‘todo’).

DCSBL avatar Apr 10 '24 10:04 DCSBL

The answer is in the stack trace, especially this part:

homeassistant.components.picnic.services.PicnicServiceException: No product found or no product ID given!

Maybe something changed in Picnic's API so it cannot find any products anymore, I'd have to check this.

corneyl avatar Apr 10 '24 11:04 corneyl

Noticed this as well. See this issue for reference.

freakshock88 avatar Apr 17 '24 19:04 freakshock88

@corneyl Any updates on this issue?

Doemas avatar May 22 '24 20:05 Doemas

It seems that there is an open PR for the library that should fix the issue but the author has not responded to the PR yet. I tried to contact the author in the PR here: https://github.com/MikeBrink/python-picnic-api/pull/25

freakshock88 avatar Jun 03 '24 18:06 freakshock88

@corneyl Could you please take a look at the above PR? Would like to be able to use this integration again. Thanks.

Doemas avatar Aug 22 '24 21:08 Doemas

Hey @corneyl Just wanted to check in on this issue. It’s been over a month, and it would be awesome to get some feedback or an update on where things stand. Appreciate all your hard work, and thanks in advance for any info you can share!

monkeydriven avatar Sep 18 '24 15:09 monkeydriven

Hi @monkeydriven, sorry, I've not been able to find time to look at this. hopefully I can find some time soon...

corneyl avatar Sep 18 '24 16:09 corneyl

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.

It is not solved yet in the newest version of HA. @corneyl do you have time to look into this?

elbert92 avatar Dec 17 '24 19:12 elbert92

This definately hasn't been fixed.

Doemas avatar Dec 18 '24 06:12 Doemas

This definately hasn't been fixed.

Just here to +1;

2025-01-17 19:36:25.251 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140040106653680] No product found or no product ID given

RobM83 avatar Jan 17 '25 19:01 RobM83

It seems Picnic has changed the search API a while ago, and a fix has been proposed. But it seems the library has been abandoned. Which is fine, priorities change, but as this is a really cool feature we should see how we can fix this for the rest.

I think the best route to fix this is forking the library and applying the proposed fixes. I am open to take over the maintenance but maybe there is a better route. @joostlek, what is common practice on an issue like this?

  • https://github.com/MikeBrink/python-picnic-api/pull/26#issuecomment-2496184172
  • https://github.com/home-assistant/core/issues/125991#issuecomment-2591135949

DCSBL avatar Jan 17 '25 20:01 DCSBL

@DCSBL seems mods are a bit too busy for this... Maybe @joostlek will reply, otherwise maybe just create a PR with the fixed code?

dhoeben avatar Feb 04 '25 17:02 dhoeben

I've gone ahead and forked the python library, merged https://github.com/MikeBrink/python-picnic-api/pull/26 and fixed https://github.com/MikeBrink/python-picnic-api/issues/27 (https://github.com/home-assistant/core/issues/138735).

I am planning to maintain this fork for as long as it is feasible* and released it on PyPi: https://pypi.org/project/python-picnic-api2/

I am currently in the middle of getting things up to date and working again so that I have a good workflow, but I already know of 3 people using the fork as a custom component in HA. The core component will only require changing the library's name, but I really want to wait for @corneyl 's feedback about this.

* It seems like picnic is migrating from a data-driven API to an API which returns hundreds of kilobytes of JSON containing hydrated widgets. This means that picnic can change the app's layout without pushing an update, but also makes life a lot harder for me, since the library has to re-arrange text, buttons, and hyperlinks into actual useful data. I do not believe this will get any easier; in fact, I bet they will change the remaining endpoints too in the future. I will try adapting to these changes as good as possible, but if things break too periodically, the picnic component might be too unstable for a core component, if at all. Additionally, one could argue that the new API falls under ADR004

codesalatdev avatar Feb 20 '25 16:02 codesalatdev

but I already know of 3 people using the fork as a custom component in HA.

@codesalatdev How do you use the fork as a custom component??

rononline avatar Feb 20 '25 23:02 rononline

@codesalatdev How do you use the fork as a custom component??

I do not want to go into too much detail here, but essentially HA lets you overwrite core components by copying the source to a custom component with the same dir name. That way, you can change the source code (and manifest file) to use the fork (python-picnic-api becomes python-picnic-api2, from python_picnic_api import ... becomes from python_picnic_api2 import ...). It's not straight forward and I wouldn't recommend it for a production environment when not absolutely necessary.

codesalatdev avatar Feb 22 '25 11:02 codesalatdev

@AnonymousMiz this is not Facebook. Please use the subscribe button for that.

Image

DCSBL avatar Feb 24 '25 08:02 DCSBL

@DCSBL Done, thanks!

AnonymousMiz avatar Feb 24 '25 08:02 AnonymousMiz