Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update on the usage of deprecated Vacuum constants & module service import. #1914

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion custom_components/localtuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.device_registry import DeviceEntry
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.service import async_register_admin_service

from .cloud_api import TuyaCloudApi
from .common import TuyaDevice, async_config_entry_by_device_id
Expand Down Expand Up @@ -162,7 +163,8 @@ async def _async_reconnect(now):

async_track_time_interval(hass, _async_reconnect, RECONNECT_INTERVAL)

hass.helpers.service.async_register_admin_service(
async_register_admin_service(
hass,
DOMAIN,
SERVICE_RELOAD,
_handle_reload,
Expand Down
22 changes: 9 additions & 13 deletions custom_components/localtuya/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
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,
VacuumEntityFeature,
VacuumActivity
)

from .common import LocalTuyaEntity, async_setup_entry
Expand Down Expand Up @@ -207,15 +203,15 @@ def status_updated(self):
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)
Expand All @@ -241,7 +237,7 @@ def status_updated(self):
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)
Loading