From 9eabc43da2414fbb96904fa3a2f4c922fae68e21 Mon Sep 17 00:00:00 2001 From: Michiel De Wilde Date: Tue, 22 Apr 2025 18:14:40 +0200 Subject: [PATCH] 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 --- custom_components/localtuya/vacuum.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/custom_components/localtuya/vacuum.py b/custom_components/localtuya/vacuum.py index 11e7a61..0ac0b1e 100644 --- a/custom_components/localtuya/vacuum.py +++ b/custom_components/localtuya/vacuum.py @@ -5,13 +5,7 @@ from functools import partial import voluptuous as vol from homeassistant.components.vacuum import ( DOMAIN, - STATE_CLEANING, - STATE_DOCKED, - STATE_ERROR, - STATE_IDLE, - STATE_PAUSED, - STATE_RETURNING, - StateVacuumEntity, VacuumEntityFeature, + StateVacuumEntity, VacuumActivity, VacuumEntityFeature, ) from .common import LocalTuyaEntity, async_setup_entry @@ -207,15 +201,15 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity): state_value = str(self.dps(self._dp_id)) if state_value in self._idle_status_list: - self._state = STATE_IDLE + self._state = VacuumActivity.IDLE 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]: - self._state = STATE_RETURNING + self._state = VacuumActivity.RETURNING elif state_value == self._config[CONF_PAUSED_STATE]: - self._state = STATE_PAUSED + self._state = VacuumActivity.PAUSED else: - self._state = STATE_CLEANING + self._state = VacuumActivity.CLEANING if self.has_config(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): self._attrs[FAULT] = self.dps_conf(CONF_FAULT_DP) if self._attrs[FAULT] != 0: - self._state = STATE_ERROR + self._state = VacuumActivity.ERROR async_setup_entry = partial(async_setup_entry, DOMAIN, LocaltuyaVacuum, flow_schema)