mirror of
https://github.com/home-assistant/core
synced 2024-09-09 12:51:22 +02:00
Remove deprecated reset_waste_drawer and set_wait_time services from litterrobot (#77052)
This commit is contained in:
parent
7fbb9c189f
commit
8c24d5810c
@ -1,12 +1,5 @@
|
|||||||
# Describes the format for available Litter-Robot services
|
# Describes the format for available Litter-Robot services
|
||||||
|
|
||||||
reset_waste_drawer:
|
|
||||||
name: Reset waste drawer
|
|
||||||
description: Reset the waste drawer level.
|
|
||||||
target:
|
|
||||||
entity:
|
|
||||||
integration: litterrobot
|
|
||||||
|
|
||||||
set_sleep_mode:
|
set_sleep_mode:
|
||||||
name: Set sleep mode
|
name: Set sleep mode
|
||||||
description: Set the sleep mode and start time.
|
description: Set the sleep mode and start time.
|
||||||
@ -27,22 +20,3 @@ set_sleep_mode:
|
|||||||
example: '"22:30:00"'
|
example: '"22:30:00"'
|
||||||
selector:
|
selector:
|
||||||
time:
|
time:
|
||||||
|
|
||||||
set_wait_time:
|
|
||||||
name: Set wait time
|
|
||||||
description: Set the wait time, in minutes, between when your cat uses the Litter-Robot and when the unit cycles automatically.
|
|
||||||
target:
|
|
||||||
entity:
|
|
||||||
integration: litterrobot
|
|
||||||
fields:
|
|
||||||
minutes:
|
|
||||||
name: Minutes
|
|
||||||
description: Minutes to wait.
|
|
||||||
required: true
|
|
||||||
default: 7
|
|
||||||
selector:
|
|
||||||
select:
|
|
||||||
options:
|
|
||||||
- "3"
|
|
||||||
- "7"
|
|
||||||
- "15"
|
|
||||||
|
@ -5,7 +5,6 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pylitterbot.enums import LitterBoxStatus
|
from pylitterbot.enums import LitterBoxStatus
|
||||||
from pylitterbot.robot.litterrobot import VALID_WAIT_TIMES
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.vacuum import (
|
from homeassistant.components.vacuum import (
|
||||||
@ -30,9 +29,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
TYPE_LITTER_BOX = "Litter Box"
|
TYPE_LITTER_BOX = "Litter Box"
|
||||||
|
|
||||||
SERVICE_RESET_WASTE_DRAWER = "reset_waste_drawer"
|
|
||||||
SERVICE_SET_SLEEP_MODE = "set_sleep_mode"
|
SERVICE_SET_SLEEP_MODE = "set_sleep_mode"
|
||||||
SERVICE_SET_WAIT_TIME = "set_wait_time"
|
|
||||||
|
|
||||||
LITTER_BOX_STATUS_STATE_MAP = {
|
LITTER_BOX_STATUS_STATE_MAP = {
|
||||||
LitterBoxStatus.CLEAN_CYCLE: STATE_CLEANING,
|
LitterBoxStatus.CLEAN_CYCLE: STATE_CLEANING,
|
||||||
@ -61,11 +58,6 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
platform = entity_platform.async_get_current_platform()
|
platform = entity_platform.async_get_current_platform()
|
||||||
platform.async_register_entity_service(
|
|
||||||
SERVICE_RESET_WASTE_DRAWER,
|
|
||||||
{},
|
|
||||||
"async_reset_waste_drawer",
|
|
||||||
)
|
|
||||||
platform.async_register_entity_service(
|
platform.async_register_entity_service(
|
||||||
SERVICE_SET_SLEEP_MODE,
|
SERVICE_SET_SLEEP_MODE,
|
||||||
{
|
{
|
||||||
@ -74,11 +66,6 @@ async def async_setup_entry(
|
|||||||
},
|
},
|
||||||
"async_set_sleep_mode",
|
"async_set_sleep_mode",
|
||||||
)
|
)
|
||||||
platform.async_register_entity_service(
|
|
||||||
SERVICE_SET_WAIT_TIME,
|
|
||||||
{vol.Required("minutes"): vol.All(vol.Coerce(int), vol.In(VALID_WAIT_TIMES))},
|
|
||||||
"async_set_wait_time",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class LitterRobotCleaner(LitterRobotControlEntity, StateVacuumEntity):
|
class LitterRobotCleaner(LitterRobotControlEntity, StateVacuumEntity):
|
||||||
@ -116,18 +103,6 @@ class LitterRobotCleaner(LitterRobotControlEntity, StateVacuumEntity):
|
|||||||
"""Start a clean cycle."""
|
"""Start a clean cycle."""
|
||||||
await self.perform_action_and_refresh(self.robot.start_cleaning)
|
await self.perform_action_and_refresh(self.robot.start_cleaning)
|
||||||
|
|
||||||
async def async_reset_waste_drawer(self) -> None:
|
|
||||||
"""Reset the waste drawer level."""
|
|
||||||
# The Litter-Robot reset waste drawer service has been replaced by a
|
|
||||||
# dedicated button entity and marked as deprecated
|
|
||||||
_LOGGER.warning(
|
|
||||||
"The 'litterrobot.reset_waste_drawer' service is deprecated and "
|
|
||||||
"replaced by a dedicated reset waste drawer button entity; Please "
|
|
||||||
"use that entity to reset the waste drawer instead"
|
|
||||||
)
|
|
||||||
await self.robot.reset_waste_drawer()
|
|
||||||
self.coordinator.async_set_updated_data(True)
|
|
||||||
|
|
||||||
async def async_set_sleep_mode(
|
async def async_set_sleep_mode(
|
||||||
self, enabled: bool, start_time: str | None = None
|
self, enabled: bool, start_time: str | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -138,17 +113,6 @@ class LitterRobotCleaner(LitterRobotControlEntity, StateVacuumEntity):
|
|||||||
self.parse_time_at_default_timezone(start_time),
|
self.parse_time_at_default_timezone(start_time),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_set_wait_time(self, minutes: int) -> None:
|
|
||||||
"""Set the wait time."""
|
|
||||||
# The Litter-Robot set wait time service has been replaced by a
|
|
||||||
# dedicated select entity and marked as deprecated
|
|
||||||
_LOGGER.warning(
|
|
||||||
"The 'litterrobot.set_wait_time' service is deprecated and "
|
|
||||||
"replaced by a dedicated set wait time select entity; Please "
|
|
||||||
"use that entity to set the wait time instead"
|
|
||||||
)
|
|
||||||
await self.perform_action_and_refresh(self.robot.set_wait_time, minutes)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return device specific state attributes."""
|
"""Return device specific state attributes."""
|
||||||
|
@ -6,15 +6,10 @@ from typing import Any
|
|||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from voluptuous.error import MultipleInvalid
|
|
||||||
|
|
||||||
from homeassistant.components.litterrobot import DOMAIN
|
from homeassistant.components.litterrobot import DOMAIN
|
||||||
from homeassistant.components.litterrobot.entity import REFRESH_WAIT_TIME_SECONDS
|
from homeassistant.components.litterrobot.entity import REFRESH_WAIT_TIME_SECONDS
|
||||||
from homeassistant.components.litterrobot.vacuum import (
|
from homeassistant.components.litterrobot.vacuum import SERVICE_SET_SLEEP_MODE
|
||||||
SERVICE_RESET_WASTE_DRAWER,
|
|
||||||
SERVICE_SET_SLEEP_MODE,
|
|
||||||
SERVICE_SET_WAIT_TIME,
|
|
||||||
)
|
|
||||||
from homeassistant.components.vacuum import (
|
from homeassistant.components.vacuum import (
|
||||||
ATTR_STATUS,
|
ATTR_STATUS,
|
||||||
DOMAIN as PLATFORM_DOMAIN,
|
DOMAIN as PLATFORM_DOMAIN,
|
||||||
@ -34,16 +29,14 @@ from .conftest import setup_integration
|
|||||||
from tests.common import async_fire_time_changed
|
from tests.common import async_fire_time_changed
|
||||||
|
|
||||||
COMPONENT_SERVICE_DOMAIN = {
|
COMPONENT_SERVICE_DOMAIN = {
|
||||||
SERVICE_RESET_WASTE_DRAWER: DOMAIN,
|
|
||||||
SERVICE_SET_SLEEP_MODE: DOMAIN,
|
SERVICE_SET_SLEEP_MODE: DOMAIN,
|
||||||
SERVICE_SET_WAIT_TIME: DOMAIN,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_vacuum(hass: HomeAssistant, mock_account: MagicMock) -> None:
|
async def test_vacuum(hass: HomeAssistant, mock_account: MagicMock) -> None:
|
||||||
"""Tests the vacuum entity was set up."""
|
"""Tests the vacuum entity was set up."""
|
||||||
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
|
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
|
||||||
assert hass.services.has_service(DOMAIN, SERVICE_RESET_WASTE_DRAWER)
|
assert hass.services.has_service(DOMAIN, SERVICE_SET_SLEEP_MODE)
|
||||||
|
|
||||||
vacuum = hass.states.get(VACUUM_ENTITY_ID)
|
vacuum = hass.states.get(VACUUM_ENTITY_ID)
|
||||||
assert vacuum
|
assert vacuum
|
||||||
@ -68,7 +61,7 @@ async def test_no_robots(
|
|||||||
"""Tests the vacuum entity was set up."""
|
"""Tests the vacuum entity was set up."""
|
||||||
await setup_integration(hass, mock_account_with_no_robots, PLATFORM_DOMAIN)
|
await setup_integration(hass, mock_account_with_no_robots, PLATFORM_DOMAIN)
|
||||||
|
|
||||||
assert not hass.services.has_service(DOMAIN, SERVICE_RESET_WASTE_DRAWER)
|
assert not hass.services.has_service(DOMAIN, SERVICE_SET_SLEEP_MODE)
|
||||||
|
|
||||||
|
|
||||||
async def test_vacuum_with_error(
|
async def test_vacuum_with_error(
|
||||||
@ -88,7 +81,6 @@ async def test_vacuum_with_error(
|
|||||||
(SERVICE_START, "start_cleaning", None),
|
(SERVICE_START, "start_cleaning", None),
|
||||||
(SERVICE_TURN_OFF, "set_power_status", None),
|
(SERVICE_TURN_OFF, "set_power_status", None),
|
||||||
(SERVICE_TURN_ON, "set_power_status", None),
|
(SERVICE_TURN_ON, "set_power_status", None),
|
||||||
(SERVICE_RESET_WASTE_DRAWER, "reset_waste_drawer", {"deprecated": True}),
|
|
||||||
(
|
(
|
||||||
SERVICE_SET_SLEEP_MODE,
|
SERVICE_SET_SLEEP_MODE,
|
||||||
"set_sleep_mode",
|
"set_sleep_mode",
|
||||||
@ -96,16 +88,6 @@ async def test_vacuum_with_error(
|
|||||||
),
|
),
|
||||||
(SERVICE_SET_SLEEP_MODE, "set_sleep_mode", {"data": {"enabled": True}}),
|
(SERVICE_SET_SLEEP_MODE, "set_sleep_mode", {"data": {"enabled": True}}),
|
||||||
(SERVICE_SET_SLEEP_MODE, "set_sleep_mode", {"data": {"enabled": False}}),
|
(SERVICE_SET_SLEEP_MODE, "set_sleep_mode", {"data": {"enabled": False}}),
|
||||||
(
|
|
||||||
SERVICE_SET_WAIT_TIME,
|
|
||||||
"set_wait_time",
|
|
||||||
{"data": {"minutes": 3}, "deprecated": True},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
SERVICE_SET_WAIT_TIME,
|
|
||||||
"set_wait_time",
|
|
||||||
{"data": {"minutes": "15"}, "deprecated": True},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_commands(
|
async def test_commands(
|
||||||
@ -137,21 +119,3 @@ async def test_commands(
|
|||||||
async_fire_time_changed(hass, future)
|
async_fire_time_changed(hass, future)
|
||||||
getattr(mock_account.robots[0], command).assert_called_once()
|
getattr(mock_account.robots[0], command).assert_called_once()
|
||||||
assert (f"'{DOMAIN}.{service}' service is deprecated" in caplog.text) is deprecated
|
assert (f"'{DOMAIN}.{service}' service is deprecated" in caplog.text) is deprecated
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_wait_time(hass: HomeAssistant, mock_account: MagicMock) -> None:
|
|
||||||
"""Test an attempt to send an invalid wait time to the vacuum."""
|
|
||||||
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
|
|
||||||
|
|
||||||
vacuum = hass.states.get(VACUUM_ENTITY_ID)
|
|
||||||
assert vacuum
|
|
||||||
assert vacuum.state == STATE_DOCKED
|
|
||||||
|
|
||||||
with pytest.raises(MultipleInvalid):
|
|
||||||
await hass.services.async_call(
|
|
||||||
DOMAIN,
|
|
||||||
SERVICE_SET_WAIT_TIME,
|
|
||||||
{ATTR_ENTITY_ID: VACUUM_ENTITY_ID, "minutes": 10},
|
|
||||||
blocking=True,
|
|
||||||
)
|
|
||||||
assert not mock_account.robots[0].set_wait_time.called
|
|
||||||
|
Loading…
Reference in New Issue
Block a user