Skip to content

Commit

Permalink
Merge pull request #1449 from cygnusb/model_re_fix
Browse files Browse the repository at this point in the history
Fix device_model parsing for multiple braces
  • Loading branch information
KartoffelToby authored Nov 7, 2024
2 parents 358cbda + d614b61 commit 94aab87
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 94aab87

Please sign in to comment.