Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid literal for int() #16

Closed
alexduf opened this issue Apr 10, 2023 · 6 comments
Closed

invalid literal for int() #16

alexduf opened this issue Apr 10, 2023 · 6 comments

Comments

@alexduf
Copy link

alexduf commented Apr 10, 2023

Hi I've just connected a dishwasher for fun an giggles, here's the stack trace I'm getting.

I'm guessing one of the sensors is expecting an int when the server is returning a float

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/hon/__init__.py", line 32, in async_setup_entry
    await hon.setup()
  File "/usr/local/lib/python3.10/site-packages/pyhon/api.py", line 61, in setup
    await asyncio.gather(*[
  File "/usr/local/lib/python3.10/site-packages/pyhon/device.py", line 115, in load_commands
    cmd = HonCommand(command, attr2, self._connector, self, multi=multi, program=program)
  File "/usr/local/lib/python3.10/site-packages/pyhon/commands.py", line 13, in __init__
    self._ancillary_parameters = self._create_parameters(attributes.get("ancillaryParameters", {}))
  File "/usr/local/lib/python3.10/site-packages/pyhon/commands.py", line 23, in _create_parameters
    result[parameter] = HonParameterRange(parameter, attributes)
  File "/usr/local/lib/python3.10/site-packages/pyhon/parameter.py", line 51, in __init__
    self._min = int(attributes["minimumValue"])
ValueError: invalid literal for int() with base 10: '0,5'
@Andre0512
Copy link
Owner

Hi, I fixed it and cast it to a float now.
I created a new beta release v0.5.0-beta.2.

@Andre0512
Copy link
Owner

Whoops I messed up, please try version v0.5.0-beta.3 🙂

@alexduf
Copy link
Author

alexduf commented Apr 11, 2023

Hey thanks for your quick responses!

Something that worries me a little and that I noticed later was how the value is using a coma instead of a dot to separate digits. ValueError: invalid literal for int() with base 10: '0,5'

I'm in France and I'm wondering if the server is formatting that to whatever locale the user is in (we would format it 0,5 in France as opposed to 0.5 in the US). Yesterday I hacked around and got it to work by casting to floats as you did, but I also had to replace , with ., which felt very hack-ish because if it were indeed formatting to a specific locale then the parsing might be more complicated :/

@Andre0512
Copy link
Owner

Hey, I take care of it and also used a replace. I saw this and found it also a little strange why they localize the api values. But here in Germany we also use comma as separator and I know these formatting problems well.
I think this isn't going to be a big problem when using the replace, if it's already a dot than just nothing gets replaced. For my washing machine there is a delay parameter with values that can go above 1000 and they doesn't use a thousand separator there, so I think this also wouldn't be a problem.

@alexduf
Copy link
Author

alexduf commented Apr 11, 2023

Brilliant, I'll test your patch tonight, thanks for your help!

@alexduf
Copy link
Author

alexduf commented Apr 12, 2023

Hey thanks, I can confirm the fix works. I'll look into supporting DW devices though I can't promise anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants