Skip to content

Commit

Permalink
Merge pull request #92 from matttbe/fan
Browse files Browse the repository at this point in the history
Add Fan sensors
  • Loading branch information
rmassch authored Nov 24, 2024
2 parents 56624f7 + c3a70a5 commit 5405d4e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/healthbox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/rmassch/healthbox-hacs/issues",
"requirements": [
"pyhealthbox3==0.0.20"
"pyhealthbox3==0.0.21"
],
"ssdp": [],
"version": "0.0.1",
Expand Down
71 changes: 71 additions & 0 deletions custom_components/healthbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
UnitOfTemperature,
PERCENTAGE,
CONCENTRATION_PARTS_PER_MILLION,
ATTR_VOLTAGE,
REVOLUTIONS_PER_MINUTE,
UnitOfPower,
UnitOfPressure,
UnitOfVolumeFlowRate,
)


Expand Down Expand Up @@ -238,6 +243,72 @@ def generate_global_sensors_for_healthbox(
value_fn=lambda x: x.wifi.ssid,
)
)

if coordinator.api.fan.voltage is not None:
global_sensors.append(
HealthboxGlobalSensorEntityDescription(
key="fan_voltage",
name="Fan Voltage",
icon="mdi:sine-wave",
native_unit_of_measurement=ATTR_VOLTAGE,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda x: x.fan.voltage,
suggested_display_precision=2,
)
)
if coordinator.api.fan.pressure is not None:
global_sensors.append(
HealthboxGlobalSensorEntityDescription(
key="fan_pressure",
name="Fan Pressure",
icon="mdi:arrow-collapse-vertical",
native_unit_of_measurement=UnitOfPressure.PA,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda x: x.fan.pressure,
suggested_display_precision=2,
)
)
if coordinator.api.fan.flow is not None:
global_sensors.append(
HealthboxGlobalSensorEntityDescription(
key="fan_flow",
name="Fan Flow",
icon="mdi:wind-power",
native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
device_class=SensorDeviceClass.VOLUME_FLOW_RATE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda x: x.fan.flow,
suggested_display_precision=2,
)
)
if coordinator.api.fan.power is not None:
global_sensors.append(
HealthboxGlobalSensorEntityDescription(
key="fan_power",
name="Fan Power",
icon="mdi:flash",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda x: x.fan.power,
suggested_display_precision=2,
)
)
if coordinator.api.fan.rpm is not None:
global_sensors.append(
HealthboxGlobalSensorEntityDescription(
key="fan_rpm",
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,
)
)

return global_sensors


Expand Down

0 comments on commit 5405d4e

Please sign in to comment.