Skip to content

Commit

Permalink
Roborock: Specify additional sensor attributes
Browse files Browse the repository at this point in the history
Using enum with options shows a dropdown of available values when building conditions or triggers in HA.
  • Loading branch information
SLaks committed Mar 19, 2024
1 parent c8f123b commit f08017f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions miio/integrations/roborock/vacuum/vacuumcontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,12 @@ def state_code(self) -> int:
return int(self.data["state"])

@property
@sensor("State", entity_category="diagnostic")
@sensor(
"State",
device_class="enum",
entity_category="diagnostic",
options=list(STATE_CODE_TO_STRING.values()),
)
def state(self) -> str:
"""Human readable state description, see also :func:`state_code`."""
return STATE_CODE_TO_STRING.get(
Expand Down Expand Up @@ -327,7 +332,12 @@ def clean_time(self) -> timedelta:
return pretty_seconds(self.data["clean_time"])

@property
@sensor("Current clean area", unit="m²", icon="mdi:texture-box")
@sensor(
"Current clean area",
unit="m²",
icon="mdi:texture-box",
suggested_display_precision=2,
)
def clean_area(self) -> float:
"""Cleaned area in m2."""
return pretty_area(self.data["clean_area"])
Expand Down Expand Up @@ -502,6 +512,7 @@ def total_duration(self) -> timedelta:
unit="m²",
icon="mdi:texture-box",
entity_category="diagnostic",
suggested_display_precision=2,
)
def total_area(self) -> float:
"""Total cleaned area."""
Expand Down Expand Up @@ -598,6 +609,7 @@ def duration(self) -> timedelta:
unit="m²",
icon="mdi:texture-box",
entity_category="diagnostic",
suggested_display_precision=2,
)
def area(self) -> float:
"""Total cleaned area."""
Expand Down

0 comments on commit f08017f

Please sign in to comment.