diff --git a/homeassistant/components/litterrobot/select.py b/homeassistant/components/litterrobot/select.py index 6dfb44e97f6..ceb20b52d40 100644 --- a/homeassistant/components/litterrobot/select.py +++ b/homeassistant/components/litterrobot/select.py @@ -23,14 +23,14 @@ async def async_setup_entry( """Set up Litter-Robot selects using config entry.""" hub: LitterRobotHub = hass.data[DOMAIN][config_entry.entry_id] - entities = [ - LitterRobotSelect( - robot=robot, entity_type=TYPE_CLEAN_CYCLE_WAIT_TIME_MINUTES, hub=hub - ) - for robot in hub.account.robots - ] - - async_add_entities(entities) + async_add_entities( + [ + LitterRobotSelect( + robot=robot, entity_type=TYPE_CLEAN_CYCLE_WAIT_TIME_MINUTES, hub=hub + ) + for robot in hub.account.robots + ] + ) class LitterRobotSelect(LitterRobotControlEntity, SelectEntity): diff --git a/homeassistant/components/litterrobot/sensor.py b/homeassistant/components/litterrobot/sensor.py index cbcb75c0b23..1fab6983249 100644 --- a/homeassistant/components/litterrobot/sensor.py +++ b/homeassistant/components/litterrobot/sensor.py @@ -98,4 +98,4 @@ async def async_setup_entry( ) ) - async_add_entities(entities, True) + async_add_entities(entities) diff --git a/homeassistant/components/litterrobot/switch.py b/homeassistant/components/litterrobot/switch.py index 3c4e4bb9937..25385ecf650 100644 --- a/homeassistant/components/litterrobot/switch.py +++ b/homeassistant/components/litterrobot/switch.py @@ -76,4 +76,4 @@ async def async_setup_entry( for switch_class, switch_type in ROBOT_SWITCHES: entities.append(switch_class(robot=robot, entity_type=switch_type, hub=hub)) - async_add_entities(entities, True) + async_add_entities(entities) diff --git a/homeassistant/components/litterrobot/vacuum.py b/homeassistant/components/litterrobot/vacuum.py index e40a971f43f..f1717bf0209 100644 --- a/homeassistant/components/litterrobot/vacuum.py +++ b/homeassistant/components/litterrobot/vacuum.py @@ -17,7 +17,7 @@ from homeassistant.components.vacuum import ( SUPPORT_STATUS, SUPPORT_TURN_OFF, SUPPORT_TURN_ON, - StateVacuumEntity, + VacuumEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import STATE_OFF @@ -47,13 +47,12 @@ async def async_setup_entry( """Set up Litter-Robot cleaner using config entry.""" hub: LitterRobotHub = hass.data[DOMAIN][entry.entry_id] - entities = [] - for robot in hub.account.robots: - entities.append( + async_add_entities( + [ LitterRobotCleaner(robot=robot, entity_type=TYPE_LITTER_BOX, hub=hub) - ) - - async_add_entities(entities, True) + for robot in hub.account.robots + ] + ) platform = entity_platform.async_get_current_platform() platform.async_register_entity_service( @@ -76,7 +75,7 @@ async def async_setup_entry( ) -class LitterRobotCleaner(LitterRobotControlEntity, StateVacuumEntity): +class LitterRobotCleaner(LitterRobotControlEntity, VacuumEntity): """Litter-Robot "Vacuum" Cleaner.""" @property diff --git a/tests/components/litterrobot/conftest.py b/tests/components/litterrobot/conftest.py index c408ed28819..c5355a218af 100644 --- a/tests/components/litterrobot/conftest.py +++ b/tests/components/litterrobot/conftest.py @@ -59,6 +59,12 @@ def mock_account_with_no_robots() -> MagicMock: return create_mock_account(skip_robots=True) +@pytest.fixture +def mock_account_with_sleeping_robot() -> MagicMock: + """Mock a Litter-Robot account with a sleeping robot.""" + return create_mock_account({"sleepModeActive": "102:00:00"}) + + @pytest.fixture def mock_account_with_error() -> MagicMock: """Mock a Litter-Robot account with error.""" diff --git a/tests/components/litterrobot/test_vacuum.py b/tests/components/litterrobot/test_vacuum.py index 7db0ca5dde4..aa0d38583e2 100644 --- a/tests/components/litterrobot/test_vacuum.py +++ b/tests/components/litterrobot/test_vacuum.py @@ -12,6 +12,7 @@ from homeassistant.components.litterrobot.vacuum import ( SERVICE_SET_WAIT_TIME, ) from homeassistant.components.vacuum import ( + ATTR_STATUS, DOMAIN as PLATFORM_DOMAIN, SERVICE_START, SERVICE_TURN_OFF, @@ -46,6 +47,17 @@ async def test_vacuum(hass: HomeAssistant, mock_account): assert vacuum.attributes["is_sleeping"] is False +async def test_vacuum_status_when_sleeping( + hass: HomeAssistant, mock_account_with_sleeping_robot +): + """Tests the vacuum status when sleeping.""" + await setup_integration(hass, mock_account_with_sleeping_robot, PLATFORM_DOMAIN) + + vacuum = hass.states.get(VACUUM_ENTITY_ID) + assert vacuum + assert vacuum.attributes.get(ATTR_STATUS) == "Ready (Sleeping)" + + async def test_no_robots(hass: HomeAssistant, mock_account_with_no_robots): """Tests the vacuum entity was set up.""" await setup_integration(hass, mock_account_with_no_robots, PLATFORM_DOMAIN)