Include config entry id in response to WS API hardware/info (#81906)
This commit is contained in:
parent
a954443795
commit
874ece195e
9 changed files with 24 additions and 0 deletions
|
@ -27,6 +27,10 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
if not board.startswith("odroid"):
|
||||
raise HomeAssistantError
|
||||
|
||||
config_entries = [
|
||||
entry.entry_id for entry in hass.config_entries.async_entries(DOMAIN)
|
||||
]
|
||||
|
||||
return [
|
||||
HardwareInfo(
|
||||
board=BoardInfo(
|
||||
|
@ -35,6 +39,7 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
model=board,
|
||||
revision=None,
|
||||
),
|
||||
config_entries=config_entries,
|
||||
dongle=None,
|
||||
name=BOARD_NAMES.get(board, f"Unknown hardkernel Odroid model '{board}'"),
|
||||
url=None,
|
||||
|
|
|
@ -34,6 +34,7 @@ class HardwareInfo:
|
|||
|
||||
name: str | None
|
||||
board: BoardInfo | None
|
||||
config_entries: list[str] | None
|
||||
dongle: USBInfo | None
|
||||
url: str | None
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
return [
|
||||
HardwareInfo(
|
||||
board=None,
|
||||
config_entries=[entry.entry_id],
|
||||
dongle=USBInfo(
|
||||
vid=entry.data["vid"],
|
||||
pid=entry.data["pid"],
|
||||
|
|
|
@ -6,6 +6,8 @@ from homeassistant.components.hassio import get_os_info
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
BOARD_NAME = "Home Assistant Yellow"
|
||||
MANUFACTURER = "homeassistant"
|
||||
MODEL = "yellow"
|
||||
|
@ -22,6 +24,10 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
if not board == "yellow":
|
||||
raise HomeAssistantError
|
||||
|
||||
config_entries = [
|
||||
entry.entry_id for entry in hass.config_entries.async_entries(DOMAIN)
|
||||
]
|
||||
|
||||
return [
|
||||
HardwareInfo(
|
||||
board=BoardInfo(
|
||||
|
@ -30,6 +36,7 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
model=MODEL,
|
||||
revision=None,
|
||||
),
|
||||
config_entries=config_entries,
|
||||
dongle=None,
|
||||
name=BOARD_NAME,
|
||||
url=None,
|
||||
|
|
|
@ -42,6 +42,10 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
if not board.startswith("rpi"):
|
||||
raise HomeAssistantError
|
||||
|
||||
config_entries = [
|
||||
entry.entry_id for entry in hass.config_entries.async_entries(DOMAIN)
|
||||
]
|
||||
|
||||
return [
|
||||
HardwareInfo(
|
||||
board=BoardInfo(
|
||||
|
@ -50,6 +54,7 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
model=MODELS.get(board),
|
||||
revision=None,
|
||||
),
|
||||
config_entries=config_entries,
|
||||
dongle=None,
|
||||
name=BOARD_NAMES.get(board, f"Unknown Raspberry Pi model '{board}'"),
|
||||
url=None,
|
||||
|
|
|
@ -48,6 +48,7 @@ async def test_hardware_info(hass: HomeAssistant, hass_ws_client) -> None:
|
|||
"model": "odroid-n2",
|
||||
"revision": None,
|
||||
},
|
||||
"config_entries": [config_entry.entry_id],
|
||||
"dongle": None,
|
||||
"name": "Home Assistant Blue / Hardkernel Odroid-N2",
|
||||
"url": None,
|
||||
|
|
|
@ -62,6 +62,7 @@ async def test_hardware_info(hass: HomeAssistant, hass_ws_client) -> None:
|
|||
"hardware": [
|
||||
{
|
||||
"board": None,
|
||||
"config_entries": [config_entry.entry_id],
|
||||
"dongle": {
|
||||
"vid": "bla_vid",
|
||||
"pid": "bla_pid",
|
||||
|
@ -74,6 +75,7 @@ async def test_hardware_info(hass: HomeAssistant, hass_ws_client) -> None:
|
|||
},
|
||||
{
|
||||
"board": None,
|
||||
"config_entries": [config_entry_2.entry_id],
|
||||
"dongle": {
|
||||
"vid": "bla_vid_2",
|
||||
"pid": "bla_pid_2",
|
||||
|
|
|
@ -48,6 +48,7 @@ async def test_hardware_info(hass: HomeAssistant, hass_ws_client) -> None:
|
|||
"model": "yellow",
|
||||
"revision": None,
|
||||
},
|
||||
"config_entries": [config_entry.entry_id],
|
||||
"dongle": None,
|
||||
"name": "Home Assistant Yellow",
|
||||
"url": None,
|
||||
|
|
|
@ -48,6 +48,7 @@ async def test_hardware_info(hass: HomeAssistant, hass_ws_client) -> None:
|
|||
"model": "1",
|
||||
"revision": None,
|
||||
},
|
||||
"config_entries": [config_entry.entry_id],
|
||||
"dongle": None,
|
||||
"name": "Raspberry Pi",
|
||||
"url": None,
|
||||
|
|
Loading…
Add table
Reference in a new issue