Skip to content

Conversation

@kysel
Copy link
Contributor

@kysel kysel commented Dec 14, 2025

This small PR adds ability to correctly convert numbers using CHAR_MAP constant.
Number can be used in heating circuit names and before this change it would error out like the traceback below.
After this change the library is able to correctly decode circuit names even with numbers
image

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 419, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mastertherm/coordinator.py", line 156, in _async_update_data
    refreshed = await self.mt_controller.refresh()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/masterthermconnect/controller.py", line 394, in refresh
    device["data"] = self.__populate_data(
                     ~~~~~~~~~~~~~~~~~~~~^
        DEVICE_READ_MAP, device["api_full_data"]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/masterthermconnect/controller.py", line 120, in __populate_data
    data[key] = self.__populate_data(device_map[key], registers)
                ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/masterthermconnect/controller.py", line 120, in __populate_data
    data[key] = self.__populate_data(device_map[key], registers)
                ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/masterthermconnect/controller.py", line 118, in __populate_data
    data[key] = self.__convert_data(item[0], item[1], registers)
                ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/masterthermconnect/controller.py", line 91, in __convert_data
    item_str = item_str + CHAR_MAP[int(registers[list_value])]
                          ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range

Signed-off-by: kysel <jkyzlink@gmail.com>
Rm Q

Signed-off-by: kysel <jkyzlink@gmail.com>
@sHedC sHedC merged commit 0f79263 into sHedC:main Dec 16, 2025
0 of 13 checks passed
@kysel kysel deleted the patch-1 branch December 16, 2025 11:47
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

Successfully merging this pull request may close these issues.

2 participants