Skip to content

Commit

Permalink
Merge pull request #544 from NickM-27/patch-2
Browse files Browse the repository at this point in the history
Fix Error For Frigate Version With Leading 0 In Commit
  • Loading branch information
dermotduffy committed Sep 25, 2023
2 parents 5ade1ac + a31922f commit 3d7f2ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit 3d7f2ca

Please sign in to comment.