custom-components / grocy

Custom Grocy integration for Home Assistant
Apache License 2.0
156 stars 47 forks source link

grocy_tasks entity doesn't pull tasks if any of the tasks are "uncategorized" or unassigned in Grocy #229

Closed birdwing closed 2 years ago

birdwing commented 2 years ago

The grocy_tasks and grocy_chores sensors occasionally has no tasks/chores in then and report a state of "unknown" I will use grocy_tasks for my example, but I believe the issue is the same for both of them.

After some testing I found that if any Task in grocy is "uncategorized" or not assigned to a user in Grocy then the tasks fail to get pulled. I checked the Grocy API to make sure it wasn't an issue there, the API sends the tasks with a empty category id if there is not category assigned. null_cat_id

I believe that the integration is expecting this to be an integer, so an empty string throws an error.

Here are some screenshots: If any task in Grocy is uncategorized uncat_task Then the entity state is "unknown" state_unknown

If all tasks have a category cat_tasks Then the entity state shows number of tasks and tasks are loaded state_correct

birdwing commented 2 years ago

I just updated grocy to version 3.3.1 today, and the issue went away. I was previously running grocy version 3.2.0.

So this appears to be an issue with grocy v3.2.0 I don't know how I missed it, but in my original API screenshot it appears that grocy wrongly put's the task category outside of the JSON object definition: screenshot_1

In a later version of grocy this was fixed: screenshot_2

This integration still says in the readme that it supports grocy version 3.2 and above. This should, I believe, be updated to say it supports grocy version 3.3 and above (to include the fixed API) or the integration needs be updated to handle the problematic JSON from the grocy 3.2 api.

marcelvriend commented 2 years ago

The issue with not categorized or unassigned tasks was recently fixed in the integration. Grocy 3.2 should still be fine. The JSON output is correct in both screenshots (curly bracket closes the assigned_to_user object).