Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix device_model parsing for multiple braces #1449

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading