mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add Venstar air filter sensors (#115832)
* Add sensors for HVAC filter usage The number of hours and the number of days are not linked. The number of hours is a sum of the hours the filter has been in use (fan running). The days is just the number of days since the filter was reset. * Update filter sensors' names * Split consumables entity descriptions and move names to translations * Scale filterHours to match real-world time It looks like the integer returned by the thermostat is actually 100 times the number of hours. * Address review comments/changes
This commit is contained in:
parent
e6c61f207d
commit
4ab3f1f41f
@ -75,7 +75,7 @@ class VenstarSensorEntityDescription(SensorEntityDescription):
|
|||||||
|
|
||||||
value_fn: Callable[[VenstarDataUpdateCoordinator, str], Any]
|
value_fn: Callable[[VenstarDataUpdateCoordinator, str], Any]
|
||||||
name_fn: Callable[[str], str] | None
|
name_fn: Callable[[str], str] | None
|
||||||
uom_fn: Callable[[Any], str | None]
|
uom_fn: Callable[[VenstarDataUpdateCoordinator], str | None]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -99,11 +99,18 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
runtimes = coordinator.runtimes[-1]
|
runtimes = coordinator.runtimes[-1]
|
||||||
entities.extend(
|
for sensor_name in runtimes:
|
||||||
VenstarSensor(coordinator, config_entry, RUNTIME_ENTITY, sensor_name)
|
if sensor_name in RUNTIME_DEVICES:
|
||||||
for sensor_name in runtimes
|
entities.append(
|
||||||
if sensor_name in RUNTIME_DEVICES
|
VenstarSensor(
|
||||||
)
|
coordinator, config_entry, RUNTIME_ENTITY, sensor_name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
entities.extend(
|
||||||
|
VenstarSensor(coordinator, config_entry, description, sensor_name)
|
||||||
|
for description in CONSUMABLE_ENTITIES
|
||||||
|
if description.key == sensor_name
|
||||||
|
)
|
||||||
|
|
||||||
for description in INFO_ENTITIES:
|
for description in INFO_ENTITIES:
|
||||||
try:
|
try:
|
||||||
@ -224,6 +231,27 @@ RUNTIME_ENTITY = VenstarSensorEntityDescription(
|
|||||||
name_fn=lambda sensor_name: f"{RUNTIME_ATTRIBUTES[sensor_name]} Runtime",
|
name_fn=lambda sensor_name: f"{RUNTIME_ATTRIBUTES[sensor_name]} Runtime",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
CONSUMABLE_ENTITIES: tuple[VenstarSensorEntityDescription, ...] = (
|
||||||
|
VenstarSensorEntityDescription(
|
||||||
|
key="filterHours",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
uom_fn=lambda _: UnitOfTime.HOURS,
|
||||||
|
value_fn=lambda coordinator, sensor_name: (
|
||||||
|
coordinator.runtimes[-1][sensor_name] / 100
|
||||||
|
),
|
||||||
|
name_fn=None,
|
||||||
|
translation_key="filter_install_time",
|
||||||
|
),
|
||||||
|
VenstarSensorEntityDescription(
|
||||||
|
key="filterDays",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
uom_fn=lambda _: UnitOfTime.DAYS,
|
||||||
|
value_fn=lambda coordinator, sensor_name: coordinator.runtimes[-1][sensor_name],
|
||||||
|
name_fn=None,
|
||||||
|
translation_key="filter_usage",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
INFO_ENTITIES: tuple[VenstarSensorEntityDescription, ...] = (
|
INFO_ENTITIES: tuple[VenstarSensorEntityDescription, ...] = (
|
||||||
VenstarSensorEntityDescription(
|
VenstarSensorEntityDescription(
|
||||||
key="schedulepart",
|
key="schedulepart",
|
||||||
|
@ -25,6 +25,12 @@
|
|||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
"filter_install_time": {
|
||||||
|
"name": "Filter installation time"
|
||||||
|
},
|
||||||
|
"filter_usage": {
|
||||||
|
"name": "Filter usage"
|
||||||
|
},
|
||||||
"schedule_part": {
|
"schedule_part": {
|
||||||
"name": "Schedule Part",
|
"name": "Schedule Part",
|
||||||
"state": {
|
"state": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user