Add hardware version to bond (#62256)

pull/62302/head
J. Nick Koston 2021-12-19 00:30:44 -06:00 committed by GitHub
parent 90345b1cf2
commit d7c5e41802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 0 deletions

View File

@ -87,6 +87,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
name=hub_name, name=hub_name,
model=hub.target, model=hub.target,
sw_version=hub.fw_ver, sw_version=hub.fw_ver,
hw_version=hub.mcu_ver,
suggested_area=hub.location, suggested_area=hub.location,
configuration_url=f"http://{host}", configuration_url=f"http://{host}",
) )

View File

@ -11,6 +11,7 @@ from aiohttp import ClientError
from bond_api import BPUPSubscriptions from bond_api import BPUPSubscriptions
from homeassistant.const import ( from homeassistant.const import (
ATTR_HW_VERSION,
ATTR_MODEL, ATTR_MODEL,
ATTR_NAME, ATTR_NAME,
ATTR_SUGGESTED_AREA, ATTR_SUGGESTED_AREA,
@ -78,6 +79,8 @@ class BondEntity(Entity):
device_info[ATTR_MODEL] = self._hub.model device_info[ATTR_MODEL] = self._hub.model
if self._hub.fw_ver is not None: if self._hub.fw_ver is not None:
device_info[ATTR_SW_VERSION] = self._hub.fw_ver device_info[ATTR_SW_VERSION] = self._hub.fw_ver
if self._hub.mcu_ver is not None:
device_info[ATTR_HW_VERSION] = self._hub.mcu_ver
else: else:
model_data = [] model_data = []
if self._device.branding_profile: if self._device.branding_profile:

View File

@ -207,6 +207,11 @@ class BondHub:
"""Return this hub firmware version.""" """Return this hub firmware version."""
return self._version.get("fw_ver") return self._version.get("fw_ver")
@property
def mcu_ver(self) -> str | None:
"""Return this hub hardware version."""
return self._version.get("mcu_ver")
@property @property
def devices(self) -> list[BondDevice]: def devices(self) -> list[BondDevice]:
"""Return a list of all devices controlled by this hub.""" """Return a list of all devices controlled by this hub."""

View File

@ -84,6 +84,7 @@ async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAss
"bondid": "test-bond-id", "bondid": "test-bond-id",
"target": "test-model", "target": "test-model",
"fw_ver": "test-version", "fw_ver": "test-version",
"mcu_ver": "test-hw-version",
} }
), patch_setup_entry("cover") as mock_cover_async_setup_entry, patch_setup_entry( ), patch_setup_entry("cover") as mock_cover_async_setup_entry, patch_setup_entry(
"fan" "fan"
@ -107,6 +108,7 @@ async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAss
assert hub.manufacturer == "Olibra" assert hub.manufacturer == "Olibra"
assert hub.model == "test-model" assert hub.model == "test-model"
assert hub.sw_version == "test-version" assert hub.sw_version == "test-version"
assert hub.hw_version == "test-hw-version"
assert hub.configuration_url == "http://some host" assert hub.configuration_url == "http://some host"
# verify supported domains are setup # verify supported domains are setup