mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Add missing LitterHopper statuses to Whisker hopper status sensor (#181342)
This commit is contained in:
@@ -75,9 +75,13 @@
|
||||
"disabled": "mdi:filter-remove",
|
||||
"empty": "mdi:filter-minus-outline",
|
||||
"enabled": "mdi:filter-check",
|
||||
"jammed": "mdi:filter-off",
|
||||
"litter_low": "mdi:filter-minus",
|
||||
"motor_disconnected": "mdi:engine-off",
|
||||
"motor_fault_short": "mdi:flash-off",
|
||||
"motor_ot_amps": "mdi:flash-alert"
|
||||
"motor_ot_amps": "mdi:flash-alert",
|
||||
"offline": "mdi:cloud-off",
|
||||
"ready": "mdi:filter-check-outline"
|
||||
}
|
||||
},
|
||||
"next_filter_replacement": {
|
||||
|
||||
@@ -128,8 +128,8 @@ ROBOT_SENSOR_MAP: dict[
|
||||
value_fn=lambda robot: robot.cycle_count,
|
||||
),
|
||||
],
|
||||
LitterRobot4: [
|
||||
RobotSensorEntityDescription[LitterRobot4](
|
||||
(LitterRobot4, LitterRobot5): [
|
||||
RobotSensorEntityDescription[LitterRobot4 | LitterRobot5](
|
||||
key="hopper_status",
|
||||
translation_key="hopper_status",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
@@ -140,6 +140,10 @@ ROBOT_SENSOR_MAP: dict[
|
||||
"motor_ot_amps",
|
||||
"motor_disconnected",
|
||||
"empty",
|
||||
"litter_low",
|
||||
"ready",
|
||||
"jammed",
|
||||
"offline",
|
||||
],
|
||||
value_fn=(
|
||||
lambda robot: (
|
||||
@@ -147,8 +151,6 @@ ROBOT_SENSOR_MAP: dict[
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
(LitterRobot4, LitterRobot5): [
|
||||
RobotSensorEntityDescription[LitterRobot4 | LitterRobot5](
|
||||
key="litter_level",
|
||||
translation_key="litter_level",
|
||||
|
||||
@@ -127,9 +127,13 @@
|
||||
"disabled": "[%key:common::state::disabled%]",
|
||||
"empty": "[%key:common::state::empty%]",
|
||||
"enabled": "[%key:common::state::enabled%]",
|
||||
"jammed": "Jammed",
|
||||
"litter_low": "Litter low",
|
||||
"motor_disconnected": "Motor disconnected",
|
||||
"motor_fault_short": "Motor shorted",
|
||||
"motor_ot_amps": "Motor overtorqued"
|
||||
"motor_ot_amps": "Motor overtorqued",
|
||||
"offline": "[%key:component::litterrobot::entity::sensor::status_code::state::offline%]",
|
||||
"ready": "[%key:component::litterrobot::entity::sensor::status_code::state::rdy%]"
|
||||
}
|
||||
},
|
||||
"last_feeding": {
|
||||
|
||||
@@ -154,6 +154,23 @@ def mock_account_with_litterhopper() -> MagicMock:
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_account_with_litterhopper_5() -> MagicMock:
|
||||
"""Mock account with LitterHopper attached to Litter-Robot 5."""
|
||||
return create_mock_account(
|
||||
robot_data={
|
||||
"state": {
|
||||
**ROBOT_5_DATA["state"],
|
||||
"hopperStatusIndicator": {
|
||||
"title": "Litter low",
|
||||
"value": HopperStatus.LITTER_LOW.value,
|
||||
},
|
||||
}
|
||||
},
|
||||
v5=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_account_with_feederrobot() -> MagicMock:
|
||||
"""Mock account with Feeder-Robot."""
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from pylitterbot.robot.litterrobot4 import HopperStatus
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.litterrobot.sensor import icon_for_gauge_level
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_OPTIONS,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorDeviceClass,
|
||||
SensorStateClass,
|
||||
@@ -147,13 +149,31 @@ async def test_pet_visits_today_sensor(
|
||||
assert sensor.state == "2"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("account_fixture", "expected_state"),
|
||||
[
|
||||
pytest.param("mock_account_with_litterhopper", "enabled", id="litter_robot_4"),
|
||||
pytest.param(
|
||||
"mock_account_with_litterhopper_5", "litter_low", id="litter_robot_5"
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_litterhopper_sensor(
|
||||
hass: HomeAssistant, mock_account_with_litterhopper: MagicMock
|
||||
hass: HomeAssistant,
|
||||
request: pytest.FixtureRequest,
|
||||
account_fixture: str,
|
||||
expected_state: str,
|
||||
) -> None:
|
||||
"""Tests LitterHopper sensors."""
|
||||
await setup_integration(hass, mock_account_with_litterhopper, SENSOR_DOMAIN)
|
||||
await setup_integration(
|
||||
hass, request.getfixturevalue(account_fixture), SENSOR_DOMAIN
|
||||
)
|
||||
sensor = hass.states.get("sensor.test_hopper_status")
|
||||
assert sensor.state == "enabled"
|
||||
assert sensor.state == expected_state
|
||||
# a status the library can report but the sensor does not declare is invalid
|
||||
assert {status.name.lower() for status in HopperStatus} <= set(
|
||||
sensor.attributes[ATTR_OPTIONS]
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
|
||||
Reference in New Issue
Block a user