mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Add Smarty versions to device (#129418)
This commit is contained in:
parent
58e151966c
commit
505a4bfc34
@ -19,6 +19,8 @@ class SmartyCoordinator(DataUpdateCoordinator[None]):
|
||||
"""Smarty Coordinator."""
|
||||
|
||||
config_entry: SmartyConfigEntry
|
||||
software_version: str
|
||||
configuration_version: str
|
||||
|
||||
def __init__(self, hass: HomeAssistant) -> None:
|
||||
"""Initialize."""
|
||||
@ -30,6 +32,12 @@ class SmartyCoordinator(DataUpdateCoordinator[None]):
|
||||
)
|
||||
self.client = Smarty(host=self.config_entry.data[CONF_HOST])
|
||||
|
||||
async def _async_setup(self) -> None:
|
||||
if not await self.hass.async_add_executor_job(self.client.update):
|
||||
raise UpdateFailed("Failed to update Smarty data")
|
||||
self.software_version = self.client.get_software_version()
|
||||
self.configuration_version = self.client.get_configuration_version()
|
||||
|
||||
async def _async_update_data(self) -> None:
|
||||
"""Fetch data from Smarty."""
|
||||
if not await self.hass.async_add_executor_job(self.client.update):
|
||||
|
@ -18,4 +18,6 @@ class SmartyEntity(CoordinatorEntity[SmartyCoordinator]):
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, coordinator.config_entry.entry_id)},
|
||||
manufacturer="Salda",
|
||||
sw_version=self.coordinator.software_version,
|
||||
hw_version=self.coordinator.configuration_version,
|
||||
)
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.const import UnitOfTemperature
|
||||
from homeassistant.const import REVOLUTIONS_PER_MINUTE, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
import homeassistant.util.dt as dt_util
|
||||
@ -64,11 +64,13 @@ ENTITIES: tuple[SmartySensorDescription, ...] = (
|
||||
SmartySensorDescription(
|
||||
key="supply_fan_speed",
|
||||
translation_key="supply_fan_speed",
|
||||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||
value_fn=lambda smarty: smarty.supply_fan_speed,
|
||||
),
|
||||
SmartySensorDescription(
|
||||
key="extract_fan_speed",
|
||||
translation_key="extract_fan_speed",
|
||||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||
value_fn=lambda smarty: smarty.extract_fan_speed,
|
||||
),
|
||||
SmartySensorDescription(
|
||||
|
@ -46,6 +46,8 @@ def mock_smarty() -> Generator[AsyncMock]:
|
||||
client.supply_fan_speed = 66
|
||||
client.extract_fan_speed = 100
|
||||
client.filter_timer = 31
|
||||
client.get_configuration_version.return_value = 111
|
||||
client.get_software_version.return_value = 127
|
||||
yield client
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'entry_type': None,
|
||||
'hw_version': None,
|
||||
'hw_version': 111,
|
||||
'id': <ANY>,
|
||||
'identifiers': set({
|
||||
tuple(
|
||||
@ -27,7 +27,7 @@
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'suggested_area': None,
|
||||
'sw_version': None,
|
||||
'sw_version': 127,
|
||||
'via_device_id': None,
|
||||
})
|
||||
# ---
|
||||
|
@ -77,13 +77,14 @@
|
||||
'supported_features': 0,
|
||||
'translation_key': 'extract_fan_speed',
|
||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_extract_fan_speed',
|
||||
'unit_of_measurement': None,
|
||||
'unit_of_measurement': 'rpm',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.mock_title_extract_fan_speed-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Mock Title Extract fan speed',
|
||||
'unit_of_measurement': 'rpm',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.mock_title_extract_fan_speed',
|
||||
@ -266,13 +267,14 @@
|
||||
'supported_features': 0,
|
||||
'translation_key': 'supply_fan_speed',
|
||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_supply_fan_speed',
|
||||
'unit_of_measurement': None,
|
||||
'unit_of_measurement': 'rpm',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.mock_title_supply_fan_speed-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Mock Title Supply fan speed',
|
||||
'unit_of_measurement': 'rpm',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.mock_title_supply_fan_speed',
|
||||
|
Loading…
x
Reference in New Issue
Block a user