Remove logic to mark litterrobot vacuum entity as unavailable (#73234)
This commit is contained in:
parent
e4f354998d
commit
21cfbe875e
3 changed files with 1 additions and 31 deletions
|
@ -1,7 +1,6 @@
|
||||||
"""Support for Litter-Robot "Vacuum"."""
|
"""Support for Litter-Robot "Vacuum"."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime, timedelta, timezone
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ LITTER_BOX_STATUS_STATE_MAP = {
|
||||||
LitterBoxStatus.CAT_SENSOR_INTERRUPTED: STATE_PAUSED,
|
LitterBoxStatus.CAT_SENSOR_INTERRUPTED: STATE_PAUSED,
|
||||||
LitterBoxStatus.OFF: STATE_OFF,
|
LitterBoxStatus.OFF: STATE_OFF,
|
||||||
}
|
}
|
||||||
UNAVAILABLE_AFTER = timedelta(minutes=30)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
|
@ -96,11 +94,6 @@ class LitterRobotCleaner(LitterRobotControlEntity, StateVacuumEntity):
|
||||||
| VacuumEntityFeature.TURN_ON
|
| VacuumEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def available(self) -> bool:
|
|
||||||
"""Return True if the cleaner has been seen recently."""
|
|
||||||
return self.robot.last_seen > datetime.now(timezone.utc) - UNAVAILABLE_AFTER
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> str:
|
def state(self) -> str:
|
||||||
"""Return the state of the cleaner."""
|
"""Return the state of the cleaner."""
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""Configure pytest for Litter-Robot tests."""
|
"""Configure pytest for Litter-Robot tests."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
|
@ -10,7 +9,6 @@ from pylitterbot.exceptions import InvalidCommandException
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import litterrobot
|
from homeassistant.components import litterrobot
|
||||||
from homeassistant.components.litterrobot.vacuum import UNAVAILABLE_AFTER
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .common import CONFIG, ROBOT_DATA
|
from .common import CONFIG, ROBOT_DATA
|
||||||
|
@ -73,14 +71,6 @@ def mock_account_with_sleep_disabled_robot() -> MagicMock:
|
||||||
return create_mock_account({"sleepModeActive": "0"})
|
return create_mock_account({"sleepModeActive": "0"})
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def mock_account_with_robot_not_recently_seen() -> MagicMock:
|
|
||||||
"""Mock a Litter-Robot account with a sleeping robot."""
|
|
||||||
return create_mock_account(
|
|
||||||
{"lastSeen": (datetime.now() - UNAVAILABLE_AFTER).isoformat()}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_account_with_error() -> MagicMock:
|
def mock_account_with_error() -> MagicMock:
|
||||||
"""Mock a Litter-Robot account with error."""
|
"""Mock a Litter-Robot account with error."""
|
||||||
|
|
|
@ -24,7 +24,7 @@ from homeassistant.components.vacuum import (
|
||||||
STATE_DOCKED,
|
STATE_DOCKED,
|
||||||
STATE_ERROR,
|
STATE_ERROR,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
|
@ -62,19 +62,6 @@ async def test_vacuum_status_when_sleeping(
|
||||||
assert vacuum.attributes.get(ATTR_STATUS) == "Ready (Sleeping)"
|
assert vacuum.attributes.get(ATTR_STATUS) == "Ready (Sleeping)"
|
||||||
|
|
||||||
|
|
||||||
async def test_vacuum_state_when_not_recently_seen(
|
|
||||||
hass: HomeAssistant, mock_account_with_robot_not_recently_seen: MagicMock
|
|
||||||
) -> None:
|
|
||||||
"""Tests the vacuum state when not seen recently."""
|
|
||||||
await setup_integration(
|
|
||||||
hass, mock_account_with_robot_not_recently_seen, PLATFORM_DOMAIN
|
|
||||||
)
|
|
||||||
|
|
||||||
vacuum = hass.states.get(VACUUM_ENTITY_ID)
|
|
||||||
assert vacuum
|
|
||||||
assert vacuum.state == STATE_UNAVAILABLE
|
|
||||||
|
|
||||||
|
|
||||||
async def test_no_robots(
|
async def test_no_robots(
|
||||||
hass: HomeAssistant, mock_account_with_no_robots: MagicMock
|
hass: HomeAssistant, mock_account_with_no_robots: MagicMock
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue