Skip to content

Commit

Permalink
Merge pull request #95 from rmassch/fix/fan-sensor-warnings
Browse files Browse the repository at this point in the history
fix: fan sensor warnings about uom and device class
  • Loading branch information
rmassch authored Nov 24, 2024
2 parents 5405d4e + e2b211c commit 59b0ce9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions custom_components/healthbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from homeassistant.const import (
UnitOfTemperature,
PERCENTAGE,
CONCENTRATION_PARTS_PER_MILLION,
ATTR_VOLTAGE,
REVOLUTIONS_PER_MINUTE,
UnitOfPower,
UnitOfPressure,
UnitOfVolumeFlowRate,
UnitOfElectricPotential
)


Expand Down Expand Up @@ -250,7 +251,7 @@ def generate_global_sensors_for_healthbox(
key="fan_voltage",
name="Fan Voltage",
icon="mdi:sine-wave",
native_unit_of_measurement=ATTR_VOLTAGE,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda x: x.fan.voltage,
Expand Down Expand Up @@ -303,7 +304,6 @@ def generate_global_sensors_for_healthbox(
name="Fan RPM",
icon="mdi:fan",
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
device_class=SensorDeviceClass.SPEED,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda x: x.fan.rpm,
)
Expand All @@ -322,7 +322,8 @@ async def async_setup_entry(
config_entry.entry_id
]

global_sensors = generate_global_sensors_for_healthbox(coordinator=coordinator)
global_sensors = generate_global_sensors_for_healthbox(
coordinator=coordinator)
room_sensors = generate_room_sensors_for_healthbox(coordinator=coordinator)
entities = []

Expand Down Expand Up @@ -350,7 +351,8 @@ def __init__(
super().__init__(coordinator)

self.entity_description = description
self._attr_unique_id = f"{coordinator.config_entry.entry_id}-{description.key}"
self._attr_unique_id = f"{
coordinator.config_entry.entry_id}-{description.key}"
self._attr_name = f"Healthbox {description.name}"
self._attr_device_info = DeviceInfo(
name=f"{coordinator.api.serial}",
Expand Down Expand Up @@ -383,14 +385,16 @@ def __init__(
super().__init__(coordinator)

self.entity_description = description
self._attr_unique_id = f"{coordinator.config_entry.entry_id}-{description.room.room_id}-{description.key}"
self._attr_unique_id = f"{
coordinator.config_entry.entry_id}-{description.room.room_id}-{description.key}"
self._attr_name = f"{description.name}"
self._attr_device_info = DeviceInfo(
name=self.entity_description.room.name,
identifiers={
(
DOMAIN,
f"{coordinator.config_entry.unique_id}_{self.entity_description.room.room_id}",
f"{coordinator.config_entry.unique_id}_{
self.entity_description.room.room_id}",
)
},
manufacturer="Renson",
Expand Down

0 comments on commit 59b0ce9

Please sign in to comment.