Skip to content

Commit

Permalink
Merge pull request #59 from bj00rn/feat/add-more-sensors
Browse files Browse the repository at this point in the history
Feat/add more sensors
  • Loading branch information
bj00rn authored Nov 26, 2024
2 parents 5154e96 + e870a48 commit cd53547
Showing 1 changed file with 69 additions and 2 deletions.
71 changes: 69 additions & 2 deletions custom_components/saleryd_hrv/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def extra_state_attributes(self):
return self._get_extra_state_attributes(value)


class SalerydHeaterPowerSensor(SalerydLokeSensor):
class SalerydLokeEstimatedHeaterPowerSensor(SalerydLokeSensor):

def _get_native_value(self, heater_power_percent: SystemProperty):
heater_power_rating = SystemProperty.from_str(
Expand All @@ -94,6 +94,17 @@ def _get_native_value(self, heater_power_percent: SystemProperty):
return None


class SalerydLokeHeaterPowerRatingSensor(SalerydLokeSensor):

def _get_native_value(self, system_property):
if system_property.value == HeaterModeEnum.Low:
return HeaterPowerEnum.Low
if system_property.value == HeaterModeEnum.High:
return HeaterPowerEnum.High

return None


class SalerydLokeErrorMessageSensor(SalerydLokeSensor):

@property
Expand Down Expand Up @@ -245,7 +256,7 @@ async def async_setup_entry(
),
),
# heater_power
SalerydHeaterPowerSensor(
SalerydLokeEstimatedHeaterPowerSensor(
coordinator,
entry,
entity_description=SensorEntityDescription(
Expand All @@ -258,6 +269,20 @@ async def async_setup_entry(
native_unit_of_measurement=UnitOfPower.WATT,
),
),
# heater_power_rating
SalerydLokeHeaterPowerRatingSensor(
coordinator,
entry,
entity_description=SensorEntityDescription(
key=DataKeyEnum.MODE_HEATER_POWER_RATING,
icon="mdi:fuse-blade",
name="Heater power rating",
device_class=SensorDeviceClass.POWER,
entity_category=EntityCategory.DIAGNOSTIC,
suggested_display_precision=0,
native_unit_of_measurement=UnitOfPower.WATT,
),
),
# supply_fan_speed
SalerydLokeSensor(
coordinator,
Expand Down Expand Up @@ -439,6 +464,48 @@ async def async_setup_entry(
device_class=SensorDeviceClass.ENUM,
),
),
# normal mode target temperature
SalerydLokeSensor(
coordinator,
entry,
entity_description=SensorEntityDescription(
key=DataKeyEnum.TARGET_TEMPERATURE_NORMAL,
icon="mdi:home-thermometer",
name="Normal temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
entity_category=EntityCategory.DIAGNOSTIC,
),
),
# Cool mode target temperature
SalerydLokeSensor(
coordinator,
entry,
entity_description=SensorEntityDescription(
key=DataKeyEnum.TARGET_TEMPERATURE_COOL,
icon="mdi:home-thermometer",
name="Cool temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
entity_category=EntityCategory.DIAGNOSTIC,
),
),
# Economy mode target temperature
SalerydLokeSensor(
coordinator,
entry,
entity_description=SensorEntityDescription(
key=DataKeyEnum.TARGET_TEMPERATURE_ECONOMY,
icon="mdi:home-thermometer",
name="Economy temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
entity_category=EntityCategory.DIAGNOSTIC,
),
),
]

async_add_entities(sensors)

0 comments on commit cd53547

Please sign in to comment.