mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Filter out non official zwave_js add-on discovery (#80110)
* Filter out non official zwave_js add-on discovery * Add test
This commit is contained in:
parent
b41cd57c33
commit
030205df8f
@ -29,6 +29,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from . import disconnect_client
|
||||
from .addon import AddonError, AddonInfo, AddonManager, AddonState, get_addon_manager
|
||||
from .const import (
|
||||
ADDON_SLUG,
|
||||
CONF_ADDON_DEVICE,
|
||||
CONF_ADDON_EMULATE_HARDWARE,
|
||||
CONF_ADDON_LOG_LEVEL,
|
||||
@ -492,6 +493,9 @@ class ConfigFlow(BaseZwaveJSFlow, config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if self._async_in_progress():
|
||||
return self.async_abort(reason="already_in_progress")
|
||||
|
||||
if discovery_info.slug != ADDON_SLUG:
|
||||
return self.async_abort(reason="not_zwave_js_addon")
|
||||
|
||||
self.ws_address = (
|
||||
f"ws://{discovery_info.config['host']}:{discovery_info.config['port']}"
|
||||
)
|
||||
|
@ -58,7 +58,8 @@
|
||||
"addon_get_discovery_info_failed": "Failed to get Z-Wave JS add-on discovery info.",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"discovery_requires_supervisor": "Discovery requires the supervisor.",
|
||||
"not_zwave_device": "Discovered device is not a Z-Wave device."
|
||||
"not_zwave_device": "Discovered device is not a Z-Wave device.",
|
||||
"not_zwave_js_addon": "Discovered add-on is not the official Z-Wave JS add-on."
|
||||
},
|
||||
"progress": {
|
||||
"install_addon": "Please wait while the Z-Wave JS add-on installation finishes. This can take several minutes.",
|
||||
|
@ -505,6 +505,28 @@ async def test_abort_hassio_discovery_with_existing_flow(
|
||||
assert result2["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
async def test_abort_hassio_discovery_for_other_addon(
|
||||
hass, supervisor, addon_installed, addon_options
|
||||
):
|
||||
"""Test hassio discovery flow is aborted for a non official add-on discovery."""
|
||||
result2 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
data=HassioServiceInfo(
|
||||
config={
|
||||
"addon": "Other Z-Wave JS",
|
||||
"host": "host1",
|
||||
"port": 3001,
|
||||
},
|
||||
name="Other Z-Wave JS",
|
||||
slug="other_addon",
|
||||
),
|
||||
)
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["reason"] == "not_zwave_js_addon"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("discovery_info", [{"config": ADDON_DISCOVERY_INFO}])
|
||||
async def test_usb_discovery(
|
||||
hass,
|
||||
|
Loading…
x
Reference in New Issue
Block a user