mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Handle unexpected versions in forked_daapd zeroconf (#37053)
This commit is contained in:
parent
e3b90ea3f7
commit
8d69a4968f
@ -156,14 +156,18 @@ class ForkedDaapdFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(self, discovery_info):
|
||||
"""Prepare configuration for a discovered forked-daapd device."""
|
||||
if not (
|
||||
discovery_info.get("properties")
|
||||
and int(discovery_info["properties"].get("mtd-version", "0").split(".")[0])
|
||||
>= 27
|
||||
and discovery_info["properties"].get("Machine Name")
|
||||
version_num = 0
|
||||
if discovery_info.get("properties") and discovery_info["properties"].get(
|
||||
"Machine Name"
|
||||
):
|
||||
try:
|
||||
version_num = int(
|
||||
discovery_info["properties"].get("mtd-version", "0").split(".")[0]
|
||||
)
|
||||
except ValueError:
|
||||
pass
|
||||
if version_num < 27:
|
||||
return self.async_abort(reason="not_forked_daapd")
|
||||
|
||||
await self.async_set_unique_id(discovery_info["properties"]["Machine Name"])
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
|
@ -158,6 +158,17 @@ async def test_config_flow_zeroconf_invalid(hass):
|
||||
) # doesn't create the entry, tries to show form but gets abort
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "not_forked_daapd"
|
||||
# test with svn mtd-version from Firefly
|
||||
discovery_info = {
|
||||
"host": "127.0.0.1",
|
||||
"port": 23,
|
||||
"properties": {"mtd-version": "svn-1676", "Machine Name": "firefly"},
|
||||
}
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||
) # doesn't create the entry, tries to show form but gets abort
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "not_forked_daapd"
|
||||
|
||||
|
||||
async def test_config_flow_zeroconf_valid(hass):
|
||||
|
Loading…
x
Reference in New Issue
Block a user