Add roomba total cleaned area sensor

This commit is contained in:
Xitee
2023-12-29 11:49:12 +01:00
parent 6eec4998bd
commit 5c6331d45a
2 changed files with 21 additions and 1 deletions

View File

@@ -11,7 +11,12 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, EntityCategory, UnitOfTime
from homeassistant.const import (
AREA_SQUARE_METERS,
PERCENTAGE,
EntityCategory,
UnitOfTime,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
@@ -114,6 +119,18 @@ SENSORS: list[RoombaSensorEntityDescription] = [
value_fn=lambda self: self.run_stats.get("nScrubs"),
entity_registry_enabled_default=False,
),
RoombaSensorEntityDescription(
key="total_cleaned_area",
translation_key="total_cleaned_area",
icon="mdi:texture-box",
native_unit_of_measurement=AREA_SQUARE_METERS,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda self: self.run_stats.get("sqft") * 9.29
if self.run_stats.get("sqft") is not None
else None,
suggested_display_precision=0,
entity_registry_enabled_default=False,
),
]

View File

@@ -84,6 +84,9 @@
},
"scrubs_count": {
"name": "Scrubs"
},
"total_cleaned_area": {
"name": "Total cleaned area"
}
}
}