kubawolanin / ha-openhab

WORK IN PROGRESS 🏠 openHAB custom integration for Home Assistant
MIT License
15 stars 5 forks source link

Error: invalid literal for int() #2

Closed BangerTech closed 2 years ago

BangerTech commented 2 years ago

After I´ve put the Files in the openhab Folder and restart I get this Error: invalid literal for int() with base 10: ´38.74......´

OH Version 3.2.0.M3 HA Version core-2021.11.1 Home Assistant OS 6.6

Bildschirmfoto 2021-11-05 um 15 53 14 Bildschirmfoto 2021-11-05 um 15 42 09
kubawolanin commented 2 years ago

It appears that it's a bug in the @sim0nx python-openhab library I use here to communicate with the OH instance:

https://github.com/sim0nx/python-openhab/blob/master/openhab/command_types.py#L230


  @classmethod
  def parse(cls, value: str) -> typing.Optional[typing.Tuple[int, int, float]]:
    """Parse a given value."""
    if value in ColorType.UNDEFINED_STATES:
      return None
    hs, ss, bs = re.split(',', value)
    h = int(hs)
    s = int(ss)
    b = float(bs)
    if not ((0 <= h <= 360) and (0 <= s <= 100) and (0 <= b <= 100)):
      raise ValueError()
    return h, s, b

it expects int whereas your Color item contains float value for h and s.

kubawolanin commented 2 years ago

@BangerTech you could try to identify which item has the problematc value by visiting http://192.168.2.193:8080/rest/items and search for 38.742856 value. Then you can try to set its state to be actually integer (round it?) Maybe it's some binding that incorrectly sets the value.

h is expected to be a big decimal: https://github.com/openhab/openhab-core/blob/f1319c283a5c5f5bdefffa070ca7d642b71f9b85/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/HSBType.java#L77

BangerTech commented 2 years ago

found it, it's a rgb wifi controller which color state is this number. It's from the Wifi LED Binding. Gotta check for rounding that number. Till then thanks a lot buddy!!!!

BangerTech commented 2 years ago

soo i´ve rounded all color leds but there is another one ;-) so maybe i´ll have to go trough all of my items haha ;-)

kubawolanin commented 2 years ago

When I'll find time I will submit a PR to python-openhab lib repo to fix this. 👍🏻

BangerTech commented 2 years ago

soo I've tried to put a state description over each item but this doesn't work out because the "real" string is still in big decimals and it's coming from the led binding so i guess there is no way on the OH side :-(

sim0nx commented 2 years ago

@kubawolanin @BangerTech I fixed that issue in release 2.16.2 ... give a try if you want and let me know if this fixes your issue. Please feel free to open issues directly at https://github.com/sim0nx/python-openhab :-)

BangerTech commented 2 years ago

yeah thanks @sim0nx now it works perfectly fine! thank you very much guys!!