Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions homeassistant/components/tuya/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,13 @@ def __init__(self, device: TuyaDevice, device_manager: TuyaDeviceManager) -> Non
self._supported_features |= SUPPORT_FAN_SPEED
self._fan_speed_type = EnumTypeData.from_json(function.values)

if function := device.function.get(DPCode.ELECTRICITY_LEFT):
if DPCode.ELECTRICITY_LEFT in self.device.status:
self._supported_features |= SUPPORT_BATTERY
self._battery_level_type = IntegerTypeData.from_json(function.values)

@property
def battery_level(self) -> int | None:
"""Return Tuya device state."""
if self._battery_level_type is None or not (
status := self.device.status.get(DPCode.ELECTRICITY_LEFT)
):
return None
return round(self._battery_level_type.scale_value(status))
return self.device.status.get(DPCode.ELECTRICITY_LEFT)
Comment thread
dougiteixeira marked this conversation as resolved.
Outdated

@property
def fan_speed(self) -> str | None:
Expand Down