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

SurePy initializes with 'TypeError: object of type 'int' has no len()' #163

Open
paulcombuse opened this issue Nov 5, 2022 · 3 comments

Comments

@paulcombuse
Copy link

The problem

I installed the Sure PetCare integration for Home Assistant and it seemed to work at first for my cat flap and the felaqua water fountain, but I keep getting the error TypeError: object of type 'int' has no len(). I have defined one household, with one pet and one person in the SurePetCare APP. Within the SurePetCare APP everything seems to work like a charm.
It seems as if the length of a string object should be determined, but the object is an integer, but I do not know.

The trouble seems to result from this line of the [surepy] repository:

responselen = len(response_data.get("data", 0))

What version of Home Assistant Core has the issue?

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

Sure PetCare

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?

Logger: homeassistant.components.surepetcare
Source: components/surepetcare/__init__.py:190
Integration: Sure Petcare (documentation, issues)

Unexpected error fetching surepetcare data: object of type 'int' has no len()
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/components/surepetcare/__init__.py", line 190, in _async_update_data
    return await self.surepy.get_entities(refresh=True)
  File "/usr/local/lib/python3.10/site-packages/surepy/__init__.py", line 400, in get_entities
    await self.get_latest_anonymous_drinks(household_id=household_id)
  File "/usr/local/lib/python3.10/site-packages/surepy/__init__.py", line 216, in get_latest_anonymous_drinks
    household_timeline = await self.get_household_timeline(household_id, entries=50)
  File "/usr/local/lib/python3.10/site-packages/surepy/__init__.py", line 266, in get_household_timeline
    if timeline := await self.sac.call(method="GET", resource=resource):
  File "/usr/local/lib/python3.10/site-packages/surepy/client.py", line 281, in call
    responselen = len(response_data.get("data", 0))
TypeError: object of type 'int' has no len()

### Additional information
Currently I have no devices or entities made available by this integration.
@gracar2002
Copy link

Appears to still be a live issue. Any workarounds?

@paulcombuse
Copy link
Author

paulcombuse commented Oct 17, 2023

@gracar2002 Well, I swapped to SureHA - same basis, but frequently updated and aligned to the most current HA versions. For me that solved the issue. Though, I do not really understand why this official repo is not updated more frequently, with the "developer" repository SureHA.
What I realized over the past years is that due to the huge efforts and plenty of test runs needed to successfully Pull Requests for a HA integration a lot of developers have a second private "developer" repository - as SureHA in this case. Additionally it can be said that (all) HA integrations should be based on Python library being called by the integration itself - as far as I understood this is a design guideline for HA developers and should keep the integrations readable and compact, just calling the functions from the respective Python library. Now, the important part is that this Python library is SurePy BUT as the integrations INCLUDE these (mostly) from PyPi.org and NOT from github.com often the Python libraries on GitHub are outdated as these are not used/called by the integrations.
Concluding the above means: if you want the most current integration release, then install HACS in your HA instance and with that install the "developer" repository - in this case SureHA which uses the most current Python library for the integration hosted at PyPi.org.

SureHA HACS integration @ github.com - release 0.4.2 (15.09.2021) --> SurePy @ PyPi.org - release 0.9.0a0 (04.04.2023)
SurePetCare integration @ github.com - release 0.104 (11.08.2023) --> SurePy @ github.com - release 0.8.0 (07.09.2022)

@gracar2002
Copy link

Happens on SureHA too - note that there is an open issue,

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

No branches or pull requests

2 participants