Skip to content

Commit

Permalink
Show firmware and hardware versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Nov 17, 2022
1 parent 19fd24e commit 9e9472e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions homeassistant/components/xiaomi_miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any, TypeVar

from construct.core import ChecksumError
from miio import Device, DeviceException
from miio import Device, DeviceException, DeviceInfo as MiioDeviceInfo

from homeassistant.const import ATTR_CONNECTIONS, CONF_MODEL
from homeassistant.helpers import device_registry as dr
Expand Down Expand Up @@ -75,10 +75,12 @@ class XiaomiMiioEntity(CoordinatorEntity[_T]):

_attr_has_entity_name = True

def __init__(self, device, entry, unique_id, coordinator):
def __init__(self, device: Device, entry, unique_id, coordinator):
"""Initialize the coordinated Xiaomi Miio Device."""
super().__init__(coordinator)
self._device = device
# TODO: make sure cached data is always used
self._device_info: MiioDeviceInfo = device.info()
self._model = entry.data[CONF_MODEL]
self._mac = entry.data[CONF_MAC]
self._device_id = entry.unique_id
Expand All @@ -91,9 +93,11 @@ def device_info(self) -> DeviceInfo:
"""Return the device info."""
device_info = DeviceInfo(
identifiers={(DOMAIN, self._device_id)},
manufacturer="Xiaomi",
default_manufacturer="Xiaomi",
model=self._model,
name=self._device_name,
hw_version=self._device_info.hardware_version,
sw_version=self._device_info.firmware_version,
)

if self._mac is not None:
Expand Down

0 comments on commit 9e9472e

Please sign in to comment.