Add support for Christmas Tree pickup to TwenteMilieu (#60822)

This commit is contained in:
Franck Nijhof 2021-12-02 10:21:19 +01:00 committed by GitHub
parent 4c158e8168
commit 42bae5439b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View file

@ -40,6 +40,13 @@ class TwenteMilieuSensorDescription(
SENSORS: tuple[TwenteMilieuSensorDescription, ...] = (
TwenteMilieuSensorDescription(
key="tree",
waste_type=WasteType.TREE,
name="Christmas Tree Pickup",
icon="mdi:pine-tree",
device_class=SensorDeviceClass.DATE,
),
TwenteMilieuSensorDescription(
key="Non-recyclable",
waste_type=WasteType.NON_RECYCLABLE,

View file

@ -69,6 +69,7 @@ def mock_twentemilieu() -> Generator[None, MagicMock, None]:
WasteType.ORGANIC: date(2021, 11, 2),
WasteType.PACKAGES: date(2021, 11, 3),
WasteType.PAPER: None,
WasteType.TREE: date(2022, 1, 6),
}
yield twentemilieu

View file

@ -22,6 +22,17 @@ async def test_waste_pickup_sensors(
entity_registry = er.async_get(hass)
device_registry = dr.async_get(hass)
state = hass.states.get("sensor.christmas_tree_pickup")
entry = entity_registry.async_get("sensor.christmas_tree_pickup")
assert entry
assert state
assert entry.unique_id == "twentemilieu_12345_tree"
assert state.state == "2022-01-06"
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Christmas Tree Pickup"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.DATE
assert state.attributes.get(ATTR_ICON) == "mdi:pine-tree"
assert ATTR_UNIT_OF_MEASUREMENT not in state.attributes
state = hass.states.get("sensor.non_recyclable_waste_pickup")
entry = entity_registry.async_get("sensor.non_recyclable_waste_pickup")
assert entry