Deprecation fix: use VacuumActivity

This fixes the following reported issue:

STATE_DOCKED was used from localtuya, this is a deprecated constant
which will be removed in HA Core 2026.1. Use VacuumActivity.DOCKED
instead, please report it to the author of the 'localtuya' custom
integration

STATE_ERROR was used from localtuya, this is a deprecated constant
which will be removed in HA Core 2026.1. Use VacuumActivity.ERROR
instead, please report it to the author of the 'localtuya' custom
integration

STATE_IDLE was used from localtuya, this is a deprecated constant
which will be removed in HA Core 2026.1. Use VacuumActivity.IDLE
instead, please report it to the author of the 'localtuya' custom
integration

STATE_PAUSED was used from localtuya, this is a deprecated constant
which will be removed in HA Core 2026.1. Use VacuumActivity.PAUSED
instead, please report it to the author of the 'localtuya' custom
integration

STATE_RETURNING was used from localtuya, this is a deprecated constant
which will be removed in HA Core 2026.1. Use VacuumActivity.RETURNING
instead, please report it to the author of the 'localtuya' custom
integration
This commit is contained in:
Michiel De Wilde
2025-04-22 18:14:40 +02:00
committed by rospogrigio
parent 2217b09286
commit 9eabc43da2

View File

@@ -5,13 +5,7 @@ from functools import partial
import voluptuous as vol import voluptuous as vol
from homeassistant.components.vacuum import ( from homeassistant.components.vacuum import (
DOMAIN, DOMAIN,
STATE_CLEANING, StateVacuumEntity, VacuumActivity, VacuumEntityFeature,
STATE_DOCKED,
STATE_ERROR,
STATE_IDLE,
STATE_PAUSED,
STATE_RETURNING,
StateVacuumEntity, VacuumEntityFeature,
) )
from .common import LocalTuyaEntity, async_setup_entry from .common import LocalTuyaEntity, async_setup_entry
@@ -207,15 +201,15 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
state_value = str(self.dps(self._dp_id)) state_value = str(self.dps(self._dp_id))
if state_value in self._idle_status_list: if state_value in self._idle_status_list:
self._state = STATE_IDLE self._state = VacuumActivity.IDLE
elif state_value in self._docked_status_list: elif state_value in self._docked_status_list:
self._state = STATE_DOCKED self._state = VacuumActivity.DOCKED
elif state_value == self._config[CONF_RETURNING_STATUS_VALUE]: elif state_value == self._config[CONF_RETURNING_STATUS_VALUE]:
self._state = STATE_RETURNING self._state = VacuumActivity.RETURNING
elif state_value == self._config[CONF_PAUSED_STATE]: elif state_value == self._config[CONF_PAUSED_STATE]:
self._state = STATE_PAUSED self._state = VacuumActivity.PAUSED
else: else:
self._state = STATE_CLEANING self._state = VacuumActivity.CLEANING
if self.has_config(CONF_BATTERY_DP): if self.has_config(CONF_BATTERY_DP):
self._battery_level = self.dps_conf(CONF_BATTERY_DP) self._battery_level = self.dps_conf(CONF_BATTERY_DP)
@@ -241,7 +235,7 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
if self.has_config(CONF_FAULT_DP): if self.has_config(CONF_FAULT_DP):
self._attrs[FAULT] = self.dps_conf(CONF_FAULT_DP) self._attrs[FAULT] = self.dps_conf(CONF_FAULT_DP)
if self._attrs[FAULT] != 0: if self._attrs[FAULT] != 0:
self._state = STATE_ERROR self._state = VacuumActivity.ERROR
async_setup_entry = partial(async_setup_entry, DOMAIN, LocaltuyaVacuum, flow_schema) async_setup_entry = partial(async_setup_entry, DOMAIN, LocaltuyaVacuum, flow_schema)