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

Integration sensors are offline (error handling issue?) #243

Closed
excalbian opened this issue Aug 13, 2022 · 4 comments · Fixed by #244
Closed

Integration sensors are offline (error handling issue?) #243

excalbian opened this issue Aug 13, 2022 · 4 comments · Fixed by #244

Comments

@excalbian
Copy link

Describe the bug
Everything in my Grocy Integration appears unavailable (see screenshot). I noticed this after upgrading the integration through HACS, although I can't guarantee that the issue wasn't happening before.

image

Investigating, I found this in my logs which appears to be related:

Logger: custom_components.grocy.coordinator
Source: helpers/update_coordinator.py:182
Integration: Grocy (documentation, issues)
First occurred: 11:05:19 AM (1 occurrences)
Last logged: 11:05:19 AM

Error fetching grocy data: Update failed: 1 validation error for ProductDetailsResponse default_quantity_unit_purchase none is not an allowed value (type=type_error.none.not_allowed)

Expected behavior
I think it would be good to have error handling so a validation error in one set of data doesn't break the whole integration. In this particular case, if Grocy allows a none default_quantity_unit_purchase, why does the integration not? Being new to both Grocy and this integration I'm not sure I understand the ecosystem well enough.

To Reproduce
I'm not sure how to reproduce. My next step is to see if I can find a product that doesn't have a default quantity unit purchase and fix it that way.

General information to help debugging:

What sensors do you have enabled? Are they working and/or what state are they in? Do you have the corresponding functions enabled in Grocy?
All are enabled both in the integration and in the Grocy add-on (within Grocy)

What is your installed versions of Home Assistant, Grocy and this integration?

HA Version

Home Assistant 2022.8.4
Supervisor 2022.08.3
Operating System 8.4
Frontend 20220802.0 - latest

Grocy Integration Version:

v4.5.1 installed via HACS

Grocy Version:

Version 3.3.1
Released on 2022-06-10 2 months ago

PHP Version 8.0.20
SQLite Version 3.38.5
OS Linux 5.15.32-v8 #1 SMP PREEMPT Sat Jul 23 18:06:19 UTC 2022 aarch64
Client Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6 Safari/605.1.15

How do you have Grocy installed? Add-on or external?
Add-on installed through the HA supervisor

Have you added debugging to the log, and what does the log say?
Not yet.

Additional context
Add any other context about the problem here.

@excalbian
Copy link
Author

I was able to continue using the integration once I removed any products in my Grocy instance that didn't have a default quantity units (both stock and purchase). For some items, I was able to add a conversion and then set the unit, but I also had to delete some product types.

It seems that the Grocy mobile app (at least on iOS) will allow you to create products without quantity units, leading to this issue.

@marcelvriend
Copy link
Contributor

The default_quantity_unit_purchase is mandatory for products for them to work correctly in Grocy. Within Grocy itself you cannot save a product without it being filled. Even if you remove a quantity unit that is still linked to certain products, those products become invalid.

The integration allows empty optional fields. But mandatory fields that Grocy requires as well, will indeed result in an error. That behavior hasn't changed lately.

@oramirite
Copy link

oramirite commented Aug 15, 2022

I just updated via HACS last night and am getting the same issue - my Grocy entities are unavailable now, and the Addon is not starting up correctly anymore. Everything was working perfectly before this update. My errors seem to be different:

Logger: homeassistant.setup
Source: setup.py:162
First occurred: 1:53:27 PM (1 occurrences)
Last logged: 1:53:27 PM

Setup failed for custom integration grocy: Unable to import component: Exception importing custom_components.grocy
This error originated from a custom integration.

Logger: homeassistant.loader
Source: custom_components/grocy/helpers.py:29
Integration: grocy (documentation, issues)
First occurred: 1:53:27 PM (1 occurrences)
Last logged: 1:53:27 PM

Unexpected exception importing component custom_components.grocy
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 584, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/custom_components/grocy/__init__.py", line 33, in <module>
    from .coordinator import GrocyDataUpdateCoordinator
  File "/config/custom_components/grocy/coordinator.py", line 20, in <module>
    from .grocy_data import GrocyData
  File "/config/custom_components/grocy/grocy_data.py", line 33, in <module>
    from .helpers import MealPlanItemWrapper, extract_base_url_and_path
  File "/config/custom_components/grocy/helpers.py", line 17, in <module>
    class MealPlanItemWrapper:
  File "/config/custom_components/grocy/helpers.py", line 29, in MealPlanItemWrapper
    def picture_url(self) -> str | None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

@marcelvriend
Copy link
Contributor

@oramirite Fixed Python 3.9 support in #244.

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

Successfully merging a pull request may close this issue.

3 participants