mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Hide broken ZBT-1 config entries on the hardware page (#142110)
* Hide bad ZBT-1 config entries on the hardware page * Set up the bad config entry in the unit test * Roll into a list comprehension * Remove constant changes * Fix condition in unit test
This commit is contained in:
parent
490e3201b9
commit
7546b5d269
@ -5,17 +5,21 @@ from __future__ import annotations
|
|||||||
from homeassistant.components.hardware.models import HardwareInfo, USBInfo
|
from homeassistant.components.hardware.models import HardwareInfo, USBInfo
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
|
||||||
|
from .config_flow import HomeAssistantSkyConnectConfigFlow
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .util import get_hardware_variant
|
from .util import get_hardware_variant
|
||||||
|
|
||||||
DOCUMENTATION_URL = "https://skyconnect.home-assistant.io/documentation/"
|
DOCUMENTATION_URL = "https://skyconnect.home-assistant.io/documentation/"
|
||||||
|
EXPECTED_ENTRY_VERSION = (
|
||||||
|
HomeAssistantSkyConnectConfigFlow.VERSION,
|
||||||
|
HomeAssistantSkyConnectConfigFlow.MINOR_VERSION,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
||||||
"""Return board info."""
|
"""Return board info."""
|
||||||
entries = hass.config_entries.async_entries(DOMAIN)
|
entries = hass.config_entries.async_entries(DOMAIN)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
HardwareInfo(
|
HardwareInfo(
|
||||||
board=None,
|
board=None,
|
||||||
@ -31,4 +35,6 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||||||
url=DOCUMENTATION_URL,
|
url=DOCUMENTATION_URL,
|
||||||
)
|
)
|
||||||
for entry in entries
|
for entry in entries
|
||||||
|
# Ignore unmigrated config entries in the hardware page
|
||||||
|
if (entry.version, entry.minor_version) == EXPECTED_ENTRY_VERSION
|
||||||
]
|
]
|
||||||
|
@ -28,6 +28,10 @@ CONFIG_ENTRY_DATA_2 = {
|
|||||||
"firmware": "ezsp",
|
"firmware": "ezsp",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONFIG_ENTRY_DATA_BAD = {
|
||||||
|
"device": "/dev/serial/by-id/usb-Nabu_Casa_Home_Assistant_Connect_ZBT-1_a87b7d75b18beb119fe564a0f320645d-if00-port0",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_hardware_info(
|
async def test_hardware_info(
|
||||||
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, addon_store_info
|
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, addon_store_info
|
||||||
@ -59,9 +63,20 @@ async def test_hardware_info(
|
|||||||
minor_version=2,
|
minor_version=2,
|
||||||
)
|
)
|
||||||
config_entry_2.add_to_hass(hass)
|
config_entry_2.add_to_hass(hass)
|
||||||
|
|
||||||
assert await hass.config_entries.async_setup(config_entry_2.entry_id)
|
assert await hass.config_entries.async_setup(config_entry_2.entry_id)
|
||||||
|
|
||||||
|
config_entry_bad = MockConfigEntry(
|
||||||
|
data=CONFIG_ENTRY_DATA_BAD,
|
||||||
|
domain=DOMAIN,
|
||||||
|
options={},
|
||||||
|
title="Home Assistant Connect ZBT-1",
|
||||||
|
unique_id="unique_3",
|
||||||
|
version=1,
|
||||||
|
minor_version=2,
|
||||||
|
)
|
||||||
|
config_entry_bad.add_to_hass(hass)
|
||||||
|
assert not await hass.config_entries.async_setup(config_entry_bad.entry_id)
|
||||||
|
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
await client.send_json({"id": 1, "type": "hardware/info"})
|
await client.send_json({"id": 1, "type": "hardware/info"})
|
||||||
@ -97,5 +112,6 @@ async def test_hardware_info(
|
|||||||
"name": "Home Assistant Connect ZBT-1",
|
"name": "Home Assistant Connect ZBT-1",
|
||||||
"url": "https://skyconnect.home-assistant.io/documentation/",
|
"url": "https://skyconnect.home-assistant.io/documentation/",
|
||||||
},
|
},
|
||||||
|
# Bad entry is skipped
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user