1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-15 07:36:16 +00:00

Add food dispensed today and next feeding sensors to litterrobot (#152016)

Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
This commit is contained in:
Nathan Spencer
2025-09-12 06:17:45 -04:00
committed by GitHub
parent 9f8f7d2fde
commit 5960179844
5 changed files with 57 additions and 0 deletions

View File

@@ -36,6 +36,9 @@
}
},
"sensor": {
"food_dispensed_today": {
"default": "mdi:counter"
},
"hopper_status": {
"default": "mdi:filter",
"state": {

View File

@@ -163,6 +163,17 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
),
],
FeederRobot: [
RobotSensorEntityDescription[FeederRobot](
key="food_dispensed_today",
translation_key="food_dispensed_today",
state_class=SensorStateClass.TOTAL,
last_reset_fn=dt_util.start_of_local_day,
value_fn=(
lambda robot: (
robot.get_food_dispensed_since(dt_util.start_of_local_day())
)
),
),
RobotSensorEntityDescription[FeederRobot](
key="food_level",
translation_key="food_level",
@@ -181,6 +192,12 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
)
),
),
RobotSensorEntityDescription[FeederRobot](
key="next_feeding",
translation_key="next_feeding",
device_class=SensorDeviceClass.TIMESTAMP,
value_fn=lambda robot: robot.next_feeding,
),
],
}

View File

@@ -59,6 +59,10 @@
}
},
"sensor": {
"food_dispensed_today": {
"name": "Food dispensed today",
"unit_of_measurement": "cups"
},
"food_level": {
"name": "Food level"
},
@@ -82,6 +86,9 @@
"litter_level": {
"name": "Litter level"
},
"next_feeding": {
"name": "Next feeding"
},
"pet_weight": {
"name": "Pet weight"
},

View File

@@ -128,6 +128,25 @@ FEEDER_ROBOT_DATA = {
"mealInsertSize": 1,
},
"updated_at": "2022-09-08T15:07:00.000000+00:00",
"active_schedule": {
"id": "1",
"name": "Feeding",
"meals": [
{
"id": "1",
"days": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
"hour": 6,
"name": "Breakfast",
"skip": None,
"minute": 30,
"paused": False,
"portions": 3,
"mealNumber": 1,
"scheduleId": None,
}
],
"created_at": "2021-12-17T07:07:31.047747+00:00",
},
},
"feeding_snack": [
{"timestamp": "2022-09-04T03:03:00.000000+00:00", "amount": 0.125},

View File

@@ -104,6 +104,7 @@ async def test_litter_robot_sensor(
assert sensor.attributes["state_class"] == SensorStateClass.TOTAL_INCREASING
@pytest.mark.freeze_time("2022-09-08 19:00:00+00:00")
async def test_feeder_robot_sensor(
hass: HomeAssistant, mock_account_with_feederrobot: MagicMock
) -> None:
@@ -117,6 +118,16 @@ async def test_feeder_robot_sensor(
assert sensor.state == "2022-09-08T18:00:00+00:00"
assert sensor.attributes["device_class"] == SensorDeviceClass.TIMESTAMP
sensor = hass.states.get("sensor.test_next_feeding")
assert sensor.state == "2022-09-09T12:30:00+00:00"
assert sensor.attributes["device_class"] == SensorDeviceClass.TIMESTAMP
sensor = hass.states.get("sensor.test_food_dispensed_today")
assert sensor.state == "0.375"
assert sensor.attributes["last_reset"] == "2022-09-08T00:00:00-07:00"
assert sensor.attributes["state_class"] == SensorStateClass.TOTAL
assert sensor.attributes["unit_of_measurement"] == "cups"
async def test_pet_weight_sensor(
hass: HomeAssistant, mock_account_with_pet: MagicMock