Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a DysonFilterLifePercentage class for the Pure Cool link #219

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions custom_components/dyson_local/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async def async_setup_entry(
entities.extend(
[
DysonFilterLifeSensor(device, name),
DysonFilterLifeSensorPercentage(device, name),
DysonParticulatesSensor(coordinator, device, name),
]
)
Expand Down Expand Up @@ -154,6 +155,22 @@ def native_value(self) -> int:
return self._device.filter_life


class DysonFilterLifeSensorPercentage(DysonSensor):
"""Dyson filter life sensor (in percentage) for Pure Cool Link."""

_SENSOR_TYPE = "filter_life_percentage"
_SENSOR_NAME = "Filter Life Percentage"
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_icon = "mdi:filter-outline"
_attr_native_unit_of_measurement = PERCENTAGE
_attr_suggested_display_precision = 0

@property
def native_value(self) -> float:
"""Return the state of the sensor calculated to a %."""
return (self._device.filter_life / 4300) * 100


class DysonCarbonFilterLifeSensor(DysonSensor):
"""Dyson carbon filter life sensor (in percentage) for Pure Cool."""

Expand Down