tomasmcguinness / homeassistant-mixergy

Add support for Mixergy's smart water tank into Home Assistant
MIT License
31 stars 8 forks source link

Integration Setup failure #53

Closed MartinCRichards closed 1 month ago

MartinCRichards commented 3 months ago

Each time I try to set up the integration I get an error :-(

I've used the Python Script you supplied elsewhere to confirm the login details and serial number match, but the log files show the error below:

2024-04-07 00:54:56.130 ERROR (MainThread) [custom_components.mixergy.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/mixergy/config_flow.py", line 82, in async_step_user
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mixergy/config_flow.py", line 49, in validate_input
    result = await tank.test_connection()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mixergy/tank.py", line 62, in test_connection
    return await self.fetch_tank_information()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mixergy/tank.py", line 346, in fetch_tank_information
    self._has_pv_diverter = (tank_configuration["mixergyPvType"] != "NO_INVERTER")
                             ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'mixergyPvType'

Guess the next step is to dump the returned configuration and see what's in there?

MartinCRichards commented 3 months ago

Had a quick play in Postman and I think this is the problem:

    "tankModelCode": "MX-180-IDE-EXT-580-1-1-B-0",
    "configuration": "{\"tankType\":\"NORMAL\"}",
    "volume": 180,

My tank doesn't return a mixergyPvType, only a tankType. I've just set the value False in tank.py and all seems to be ok now!

tomasmcguinness commented 2 months ago

Sorry about that Martin!

The API is a bit of a pain - I'll look at getting a fix in ASAP.

MartinCRichards commented 1 month ago

Nice one, thank you!