gvigroux / hon

Support of all Haier, Candy, Hoover appliances integrated in the official hOn mobile app. Direct access to all possible services and parameters
MIT License
118 stars 45 forks source link

Locale related error "invalid literal for int() with base 10: '0,5'" #96

Closed bo4arov closed 1 year ago

bo4arov commented 1 year ago

App version: latest Stacktrace:

Traceback (most recent call last):
  File "/config/custom_components/hon/parameter.py", line 54, in __init__
    self._min = int(attributes["minimumValue"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '0,5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hon/__init__.py", line 77, in async_setup_entry
    await coordinator.device.load_commands()
  File "/config/custom_components/hon/device.py", line 184, in load_commands
    cmd = HonCommand(command, attr2, self._hon, self, multi=multi, program=program)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hon/command.py", line 16, in __init__
    self._ancillary_parameters = self._create_parameters(attributes.get("ancillaryParameters", {}))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hon/command.py", line 26, in _create_parameters
    result[parameter] = HonParameterRange(parameter, attributes)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hon/parameter.py", line 59, in __init__
    self._min = float(attributes["minimumValue"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '0,5'

Greetings! After trying to login into the app i receive the unexpected error, please see the above. Looking into the logs, it looks like it's somehow connected to the locale settings. I added additional logging after the user login to dump the Cognito user info into the log. From it, I can see server's response containing salesForceUser.locale = it_IT, salesForceUser.custom_attributes.Country = PL, salesForceUser.custom_attributes.UserLanguage = en_GB. I tried changing the country in my profile to GB, but this didn't change anything. Also i have no idea why the locale is set to Italy - do they host their infra in Italy?
Please advise.

gvigroux commented 1 year ago

I will try to do a fix to avoid the locale issue

gvigroux commented 1 year ago

I have create a beta. Can you please test ? https://github.com/gvigroux/hon/releases/tag/0.5.2-Beta

bo4arov commented 1 year ago

Wow, thank you! i did give a try and it allowed me to log in!
Though, looks like some of the features aren't working :( e.g. when i try to change AC temperature, it returns me and error

Failed to call service climate/set_temperature. 'float' object has no attribute 'replace'. image

So there are probably the other things to be tweaked. Unfortunately can't say what exactly since i'm not really a python guy :(

gvigroux commented 1 year ago

You have an AC with the 0.5 precision (I don't have it, I guess that's why). I will do another fix

gvigroux commented 1 year ago

Let's try this one :) https://github.com/gvigroux/hon/releases/tag/0.5.2-Beta2

gvigroux commented 1 year ago

I'm closing this because it should work now