Add roomba total cleaned area sensor (#106640)

* Add roomba total cleaned area sensor

* Use parentheses for multi-line lambda

* Update homeassistant/components/roomba/sensor.py

Co-authored-by: Jan-Philipp Benecke <github@bnck.me>

* Update homeassistant/components/roomba/sensor.py

Co-authored-by: Jan-Philipp Benecke <github@bnck.me>

* Revert "Update homeassistant/components/roomba/sensor.py"

This reverts commit 819be6179f.

---------

Co-authored-by: Jan-Philipp Benecke <github@bnck.me>
pull/106674/head
Xitee 2023-12-29 15:52:38 +01:00 committed by GitHub
parent 02b863e968
commit 2add7707b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 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,20 @@ 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"
}
}
}