mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Add total cycles sensor for Litter-Robot (#147435)
* Add total cycles sensor for Litter-Robot * Add translatable unit of measurement cycles
This commit is contained in:
parent
657a068087
commit
54e5107c34
@ -46,6 +46,9 @@
|
|||||||
"motor_fault_short": "mdi:flash-off",
|
"motor_fault_short": "mdi:flash-off",
|
||||||
"motor_ot_amps": "mdi:flash-alert"
|
"motor_ot_amps": "mdi:flash-alert"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"total_cycles": {
|
||||||
|
"default": "mdi:counter"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"switch": {
|
"switch": {
|
||||||
|
@ -115,6 +115,14 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
|
|||||||
lambda robot: status.lower() if (status := robot.status_code) else None
|
lambda robot: status.lower() if (status := robot.status_code) else None
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
RobotSensorEntityDescription[LitterRobot](
|
||||||
|
key="total_cycles",
|
||||||
|
translation_key="total_cycles",
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
value_fn=lambda robot: robot.cycle_count,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
LitterRobot4: [
|
LitterRobot4: [
|
||||||
RobotSensorEntityDescription[LitterRobot4](
|
RobotSensorEntityDescription[LitterRobot4](
|
||||||
|
@ -118,6 +118,10 @@
|
|||||||
"spf": "Pinch detect at startup"
|
"spf": "Pinch detect at startup"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"total_cycles": {
|
||||||
|
"name": "Total cycles",
|
||||||
|
"unit_of_measurement": "cycles"
|
||||||
|
},
|
||||||
"waste_drawer": {
|
"waste_drawer": {
|
||||||
"name": "Waste drawer"
|
"name": "Waste drawer"
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,11 @@ from unittest.mock import MagicMock
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.litterrobot.sensor import icon_for_gauge_level
|
from homeassistant.components.litterrobot.sensor import icon_for_gauge_level
|
||||||
from homeassistant.components.sensor import DOMAIN as PLATFORM_DOMAIN, SensorDeviceClass
|
from homeassistant.components.sensor import (
|
||||||
|
DOMAIN as PLATFORM_DOMAIN,
|
||||||
|
SensorDeviceClass,
|
||||||
|
SensorStateClass,
|
||||||
|
)
|
||||||
from homeassistant.const import PERCENTAGE, STATE_UNKNOWN, UnitOfMass
|
from homeassistant.const import PERCENTAGE, STATE_UNKNOWN, UnitOfMass
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
@ -70,6 +74,7 @@ async def test_gauge_icon() -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.freeze_time("2022-09-18 23:00:44+00:00")
|
@pytest.mark.freeze_time("2022-09-18 23:00:44+00:00")
|
||||||
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||||
async def test_litter_robot_sensor(
|
async def test_litter_robot_sensor(
|
||||||
hass: HomeAssistant, mock_account_with_litterrobot_4: MagicMock
|
hass: HomeAssistant, mock_account_with_litterrobot_4: MagicMock
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -94,6 +99,9 @@ async def test_litter_robot_sensor(
|
|||||||
sensor = hass.states.get("sensor.test_pet_weight")
|
sensor = hass.states.get("sensor.test_pet_weight")
|
||||||
assert sensor.state == "12.0"
|
assert sensor.state == "12.0"
|
||||||
assert sensor.attributes["unit_of_measurement"] == UnitOfMass.POUNDS
|
assert sensor.attributes["unit_of_measurement"] == UnitOfMass.POUNDS
|
||||||
|
sensor = hass.states.get("sensor.test_total_cycles")
|
||||||
|
assert sensor.state == "158"
|
||||||
|
assert sensor.attributes["state_class"] == SensorStateClass.TOTAL_INCREASING
|
||||||
|
|
||||||
|
|
||||||
async def test_feeder_robot_sensor(
|
async def test_feeder_robot_sensor(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user