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

Migrate unique id in Trafikverket Camera #101937

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add logging
  • Loading branch information
gjohansson-ST committed Oct 14, 2023
commit 25ed5bc8c43534f9e8eb0888ee80a832632b090b
4 changes: 4 additions & 0 deletions homeassistant/components/trafikverket_camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
try:
camera_info = await camera_api.async_get_camera(location)
except Exception: # pylint: disable=broad-except
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to be more specific in the expected exception?

_LOGGER.error(
"Could not migrate the config entry. No connection to the api"
)
return False

if camera_id := camera_info.camera_id:
Expand All @@ -66,5 +69,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unique_id=f"{DOMAIN}-{camera_id}",
Copy link
Member

@MartinHjelmare MartinHjelmare Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we prefix the domain to the unique id?

)
return True
_LOGGER.error("Could not migrate the config entry. Camera has no id")
return False
return True