From ee669383cc7140a4c76277146b10c323a7ec9fc9 Mon Sep 17 00:00:00 2001 From: Dante F Date: Fri, 3 Jan 2025 09:30:10 -0500 Subject: [PATCH 1/2] Changes to fix issue #673, AREA_SQUARE_METERS deprecated --- custom_components/roborock/sensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/roborock/sensor.py b/custom_components/roborock/sensor.py index 7a83237..c64c959 100644 --- a/custom_components/roborock/sensor.py +++ b/custom_components/roborock/sensor.py @@ -16,7 +16,7 @@ SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import AREA_SQUARE_METERS, PERCENTAGE, UnitOfTime +from homeassistant.const import UnitOfArea.SQUARE_METERS, PERCENTAGE, UnitOfTime from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -100,7 +100,7 @@ class RoborockSensorDescription(SensorEntityDescription): entity_category=EntityCategory.DIAGNOSTIC, ), f"last_clean_{ATTR_LAST_CLEAN_AREA}": RoborockSensorDescription( - native_unit_of_measurement=AREA_SQUARE_METERS, + native_unit_of_measurement=UnitOfArea.SQUARE_METERS, key="area", value=lambda value, _: round(value / 1000000, 1), icon="mdi:texture-box", From 5d5e8c34dcb919304b4efb423d28ca296bbe66e0 Mon Sep 17 00:00:00 2001 From: Dante F Date: Fri, 3 Jan 2025 10:04:29 -0500 Subject: [PATCH 2/2] Update sensor.py Additional fixes for the same issue --- custom_components/roborock/sensor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/roborock/sensor.py b/custom_components/roborock/sensor.py index c64c959..555a67c 100644 --- a/custom_components/roborock/sensor.py +++ b/custom_components/roborock/sensor.py @@ -16,7 +16,7 @@ SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import UnitOfArea.SQUARE_METERS, PERCENTAGE, UnitOfTime +from homeassistant.const import UnitOfArea, PERCENTAGE, UnitOfTime from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -130,7 +130,7 @@ class RoborockSensorDescription(SensorEntityDescription): entity_category=EntityCategory.DIAGNOSTIC, ), f"current_{ATTR_STATUS_CLEAN_AREA}": RoborockSensorDescription( - native_unit_of_measurement=AREA_SQUARE_METERS, + native_unit_of_measurement=UnitOfArea.SQUARE_METERS, icon="mdi:texture-box", key="clean_area", value=lambda value, _: round(value / 1000000, 1), @@ -174,7 +174,7 @@ class RoborockSensorDescription(SensorEntityDescription): entity_category=EntityCategory.DIAGNOSTIC, ), f"clean_history_{ATTR_CLEAN_SUMMARY_TOTAL_AREA}": RoborockSensorDescription( - native_unit_of_measurement=AREA_SQUARE_METERS, + native_unit_of_measurement=UnitOfArea.SQUARE_METERS, key="clean_area", value=lambda value, _: round(value / 1000000, 1), icon="mdi:texture-box",