Skip to content

Commit

Permalink
Fix device_model parsing for multiple braces
Browse files Browse the repository at this point in the history
only get last value in braces. model description can also contain braces.
Example Bosch: Room thermostat II (Battery model) (BTH-RM)
  • Loading branch information
cygnusb committed Nov 7, 2024
1 parent 358cbda commit d614b61
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions custom_components/better_thermostat/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,9 @@ async def get_device_model(self, entity_id):
_LOGGER.debug(device)
try:
# Z2M reports the device name as a long string with the actual model name in braces, we need to extract it
return re.search("\\((.+?)\\)", device.model).group(1)
except AttributeError:
matches = re.findall(r"\((.+?)\)", device.model)
return matches[-1]
except IndexError:
# Other climate integrations might report the model name plainly, need more infos on this
return device.model
except (
Expand Down

0 comments on commit d614b61

Please sign in to comment.