ckarrie / oekofen-api

MIT License
3 stars 0 forks source link

TypeError: can't multiply sequence by non-int of type 'float' #1

Closed carl-mayer closed 1 year ago

carl-mayer commented 1 year ago

oekofen api v0.0.22 Oekofen CONDENS V4.00b

Executing the following test script fails with TypeError: can't multiply sequence by non-int of type 'float'

import oekofen_api
import time

client = oekofen_api.Oekofen("<ip address>", "<password>")
#client.update_csv_data()
x = client.update_data()
_fetch_data using urllib.request.urlopen http://<ip address>:4321/<password>/all?
Traceback (most recent call last):
  File "/Users/carl/Downloads/oekofen-api/test.py", line 6, in <module>
    x = client.update_data()
        ^^^^^^^^^^^^^^^^^^^^
  File "/Users/carl/Downloads/oekofen-api/oekofen_api/__init__.py", line 89, in update_data
    att_rendered_value = self._get_value(
                         ^^^^^^^^^^^^^^^^
  File "/Users/carl/Downloads/oekofen-api/oekofen_api/__init__.py", line 214, in _get_value
    return attribute_instance.get_value()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/carl/Downloads/oekofen-api/oekofen_api/__init__.py", line 356, in get_value
    v = value * self.factor
        ~~~~~~^~~~~~~~~~~~~
TypeError: can't multiply sequence by non-int of type 'float'

https://github.com/ckarrie/oekofen-api/blob/main/oekofen_api/__init__.py#L356

Changing line 356 to

v = float(value) * self.factor

resolves the issue (in my environment).

ckarrie commented 1 year ago

Thanks for your comment, I will update the code asap