vincentwolsink / home_assistant_micronova_agua_iot

Home Assistant integration controlling heating devices connected via the Agua IOT platform of Micronova
Apache License 2.0
25 stars 15 forks source link

ATTR_REAL_POWER - ValueError: could not convert string to float: 'int(0' #15

Closed VonOx closed 1 year ago

VonOx commented 1 year ago

Hi, just a little bug

Seems my stove have no ATTR_REAL_POWER

Removed L132 from climate.py but is there a better way to handle this ?

Log for reference

2023-06-14 11:22:16.855 ERROR (MainThread) [homeassistant.components.climate] Error adding entities for domain climate with platform aguaiot
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 471, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 749, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 850, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 657, in _async_write_ha_state
    attr.update(self.extra_state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/aguaiot/climate.py", line 132, in extra_state_attributes
    ATTR_REAL_POWER: self._device.real_power,
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/py_agua_iot/__init__.py", line 710, in real_power
    return int(self.__get_information_item("real_power_get"))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/py_agua_iot/__init__.py", line 490, in __get_information_item
    eval_formula = formula_parser.parser(formula)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/py_agua_iot/formula_parser.py", line 47, in parser
    lis[i] = evaluate_mul_div(lis[i])
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/py_agua_iot/formula_parser.py", line 27, in evaluate_mul_div
    output = float(lis[0])
             ^^^^^^^^^^^^^
ValueError: could not convert string to float: 'int(0'

Thank you by the way

vincentwolsink commented 1 year ago

Hi @VonOx, can you check if v0.1.4-beta2 fixes the issue for you?

VonOx commented 1 year ago

Hi , tested beta3 and no error anymore, thank you Vincent.