Remove tuya vacuum battery level attribute (#150086)

This commit is contained in:
epenet
2025-08-06 11:02:04 +02:00
committed by Franck Nijhof
parent 4e21ef5fbc
commit d2586ca4ff
2 changed files with 8 additions and 15 deletions

View File

@@ -915,6 +915,13 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
translation_key="rolling_brush_life", translation_key="rolling_brush_life",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
TuyaSensorEntityDescription(
key=DPCode.ELECTRICITY_LEFT,
translation_key="battery",
device_class=SensorDeviceClass.BATTERY,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,
),
), ),
# Smart Water Timer # Smart Water Timer
"sfkzq": ( "sfkzq": (

View File

@@ -18,7 +18,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import TuyaConfigEntry from . import TuyaConfigEntry
from .const import TUYA_DISCOVERY_NEW, DPCode, DPType from .const import TUYA_DISCOVERY_NEW, DPCode, DPType
from .entity import TuyaEntity from .entity import TuyaEntity
from .models import EnumTypeData, IntegerTypeData from .models import EnumTypeData
TUYA_MODE_RETURN_HOME = "chargego" TUYA_MODE_RETURN_HOME = "chargego"
TUYA_STATUS_TO_HA = { TUYA_STATUS_TO_HA = {
@@ -77,7 +77,6 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
"""Tuya Vacuum Device.""" """Tuya Vacuum Device."""
_fan_speed: EnumTypeData | None = None _fan_speed: EnumTypeData | None = None
_battery_level: IntegerTypeData | None = None
_attr_name = None _attr_name = None
def __init__(self, device: CustomerDevice, device_manager: Manager) -> None: def __init__(self, device: CustomerDevice, device_manager: Manager) -> None:
@@ -118,19 +117,6 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
self._attr_fan_speed_list = enum_type.range self._attr_fan_speed_list = enum_type.range
self._attr_supported_features |= VacuumEntityFeature.FAN_SPEED self._attr_supported_features |= VacuumEntityFeature.FAN_SPEED
if int_type := self.find_dpcode(DPCode.ELECTRICITY_LEFT, dptype=DPType.INTEGER):
self._attr_supported_features |= VacuumEntityFeature.BATTERY
self._battery_level = int_type
@property
def battery_level(self) -> int | None:
"""Return Tuya device state."""
if self._battery_level is None or not (
status := self.device.status.get(DPCode.ELECTRICITY_LEFT)
):
return None
return round(self._battery_level.scale_value(status))
@property @property
def fan_speed(self) -> str | None: def fan_speed(self) -> str | None:
"""Return the fan speed of the vacuum cleaner.""" """Return the fan speed of the vacuum cleaner."""