GithubHelp home page GithubHelp logo

Comments (16)

henfri avatar henfri commented on June 28, 2024

Hello,

the problem occurs here:

    def _fetch(self):
        self._api.get_products()
        products = self._api.data

        for attr, val in products[self._dev_id].items():
            setattr(self, str(attr), val)

So it seems that "products" for some reason is True or False rather than a data-structure.
products = self._api.data

So, after

    def __init__(self):
        self._worx_mqtt_client_id = ''
        self._worx_mqtt_endpoint = ''

        self._api = WorxLandroidAPI()

The only reason for _api to be Bool, that I see is this:

@MTrab What do you think?

Best regards,
Hendrik

from pyworxcloud.

henfri avatar henfri commented on June 28, 2024

Hi Morten,

could you please consider this fix and release a new version of pyworxcloud?

Best regards,
Hendrik

from pyworxcloud.

MTrab avatar MTrab commented on June 28, 2024

@henfri is this still an issue on the latest release?

from pyworxcloud.

MTrab avatar MTrab commented on June 28, 2024

Strange - we are not seeing this issue in Home Assistant.
Is it every time you poll the API or only occasional?

from pyworxcloud.

henfri avatar henfri commented on June 28, 2024

Hello,
sorry, I was on holidays.
I am using 1.4.13, I think this is the latest release.

  File "/usr/local/smarthome/lib/scheduler.py", line 657, in _task
    obj()
  File "/usr/local/smarthome/plugins/landroid/__init__.py", line 345, in poll_device
    self.worx.update()
  File "/usr/local/lib/python3.8/site-packages/pyworxcloud/__init__.py", line 300, in update
    self._fetch()
  File "/usr/local/lib/python3.8/site-packages/pyworxcloud/__init__.py", line 294, in _fetch
    for attr, val in products[self._dev_id].items():
AttributeError: 'str' object has no attribute 'items'

So, it seems that "products" as returned by the API could be

  • list (expected)
  • bool (see my initial error)
  • str (see above)

I think, this should be caught by the code:

if type(products)=='list':
  for attr, val in products[self._dev_id].items():
else:
  logger.warning(...)

Or similar.
Currently, I am getting this Error on every call. Previously, it was working though (without me changing any code).

Best regards,
Hendrik

from pyworxcloud.

MTrab avatar MTrab commented on June 28, 2024

Can you post the code you are using for this call?
Again - this is not an issue we see using this with Home Assistant

from pyworxcloud.

henfri avatar henfri commented on June 28, 2024

Hello,

yes, it would be good to understand why the API provides bool or str sometimes for us...
You find the call of update() here:
https://github.com/Andrek01/landroid/blob/134aa286577a58afead2083b461f899ec65c89d3/plugins/__init__.py#L343
The only call that is done before is this one:
https://github.com/Andrek01/landroid/blob/134aa286577a58afead2083b461f899ec65c89d3/plugins/__init__.py#L225

So basically:

self.auth = self.worx.initialize(self.user,self.pwd)  #called once
if self.auth: #called every 300s
    try:
        self.worx.update()
        self.worx.getStatus()

Note that the Code at github has try/except around which I don't have for my running code in order to see this issue.

Best regards,
Hendrik

from pyworxcloud.

MTrab avatar MTrab commented on June 28, 2024

Using this quick test code, I don't see any errors.

https://gist.github.com/MTrab/abcce994ba0e1e10652455d456bb6363

from pyworxcloud.

henfri avatar henfri commented on June 28, 2024

Hello,

thanks, I am testing now.

Greetings,
Hendrik

from pyworxcloud.

henfri avatar henfri commented on June 28, 2024

Hello,

I get many successes, but then:

Updating Worx
 - Update done
Sleeping 300 seconds
Updating Worx
 - Update done
Sleeping 300 seconds
Updating Worx
Error: Unauthorized
Ooops - something went wrong!

Best regards,
Hendrik

from pyworxcloud.

MTrab avatar MTrab commented on June 28, 2024

Yup, that's a known bug. It's actually a timeout handled wrong

from pyworxcloud.

henfri avatar henfri commented on June 28, 2024

Ok, but that is not the same one as the one, that I was reporting, right?

File "/home/smarthome/.local/lib/python3.9/site-packages/pyworxcloud/init.py", line 293, in _fetch
for attr, val in products[self._dev_id].items():
TypeError: 'bool' object is not subscriptable`

Or would the kown bug then lead also to my issue?

Best regards,
Hendrik

from pyworxcloud.

MTrab avatar MTrab commented on June 28, 2024

No, this error is, althou incorrectly, handled by the API.
The one you reported is unhandled, so not the same.

BUT - if the test code is not producing this error, I'd say it's something in the way you are using the module.

from pyworxcloud.

henfri avatar henfri commented on June 28, 2024

Hello,

would you have any Idea?
A significant difference is, that I do not use asyncio... But my code is super simple... So I would not know, what the reason could be...

Greetings,
Hendrik

from pyworxcloud.

MTrab avatar MTrab commented on June 28, 2024

Can you post your full code to trigger the issue?
I'd really like to fix this, but as I can't seem to reproduce it's rather hard to guess what need to be changed and still be compatible with either systems.

from pyworxcloud.

MTrab avatar MTrab commented on June 28, 2024

Will close this issue as version 2 is right on the steps, containing major (BREAKING!) changes

from pyworxcloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.