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 Error For Frigate Version With Leading 0 In Commit #544

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion custom_components/frigate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except FrigateApiClientError as exc:
raise ConfigEntryNotReady from exc

if AwesomeVersion(server_version) <= AwesomeVersion(FRIGATE_VERSION_ERROR_CUTOFF):
if AwesomeVersion(server_version.split("-")[0]) <= AwesomeVersion(
FRIGATE_VERSION_ERROR_CUTOFF
):
_LOGGER.error(
"Using a Frigate server (%s) with version %s <= %s which is not "
"compatible -- you must upgrade: %s",
Expand Down
13 changes: 13 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ async def test_entry_async_get_version_incompatible(hass: HomeAssistant) -> None
assert config_entry.state == ConfigEntryState.SETUP_ERROR


async def test_entry_async_get_version_compatible_leading_zero(
hass: HomeAssistant,
) -> None:
"""Test running an incompatible server version."""

client = create_mock_frigate_client()
client.async_get_version = AsyncMock(return_value="0.13.0-0858859")

config_entry = await setup_mock_frigate_config_entry(hass, client=client)
print(config_entry.state)
assert config_entry.state == ConfigEntryState.LOADED


async def test_entry_migration_v1_to_v2(hass: HomeAssistant) -> None:
"""Test migrating a config entry."""
entity_registry = er.async_get(hass)
Expand Down