kamaradclimber / heishamon-homeassistant

An integration for heatpumps handled by heishamon
Apache License 2.0
50 stars 25 forks source link

Error regarding SetDemandControl #252

Closed b3nn0 closed 2 months ago

b3nn0 commented 2 months ago

Versions

Describe the bug

Hi, as of one of the more recent versions (I think 1.13.0?) I'm often seeing this error in my HA log:

2024-09-15 18:10:04.266 ERROR (MainThread) [homeassistant.components.mqtt.client] Exception in message_received when handling msg on 'panasonic_heat_pump/commands/SetDemandControl': '81.2'
Traceback (most recent call last):
  File "/config/custom_components/aquarea/number.py", line 100, in message_received
    self._attr_native_value = self.entity_description.state(message.payload)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/aquarea/definitions.py", line 356, in read_demandcontrol
    i = int(value)
        ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '81.2'

Looks like there is some misinterpretation/invalid casting to int happening there.. Demand control is set to 20%. Setting it to other values yields similar errors. The value in the topic is written by this integration as a float (which is probably incorrect?)

kamaradclimber commented 2 months ago

indeed this is a bug: since there is no way to get the current value of demandcontrol, HA listens to the same topic where we send the command. It means you want to write 20%, we send the string 81.2 to heishamon via mqtt. HA receives 81.2 and tries to read it as an int :face_exhaling: . I'll fix this. Thanks for reporting!

kamaradclimber commented 2 months ago

Fixed in https://github.com/kamaradclimber/heishamon-homeassistant/releases/tag/1.13.2

b3nn0 commented 2 months ago

Unfortunately, I think it's still doing something wrong. The error is gone, but now there seems to be some rounding issue. E.g. when I set demand control to 20% in HA, it will automatically be set to 19% with the next update, which doesn't seem to be a valid value. Nothing dramatic, just slightly annoying.