Migrate Twente Milieu to new entity naming style (#74593)
This commit is contained in:
parent
63582c3f98
commit
81e7eb623b
5 changed files with 40 additions and 23 deletions
|
@ -28,7 +28,7 @@ async def async_setup_entry(
|
|||
class TwenteMilieuCalendar(TwenteMilieuEntity, CalendarEntity):
|
||||
"""Defines a Twente Milieu calendar."""
|
||||
|
||||
_attr_name = "Twente Milieu"
|
||||
_attr_has_entity_name = True
|
||||
_attr_icon = "mdi:delete-empty"
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -15,9 +15,9 @@ CONF_HOUSE_NUMBER = "house_number"
|
|||
CONF_HOUSE_LETTER = "house_letter"
|
||||
|
||||
WASTE_TYPE_TO_DESCRIPTION = {
|
||||
WasteType.NON_RECYCLABLE: "Non-recyclable Waste Pickup",
|
||||
WasteType.ORGANIC: "Organic Waste Pickup",
|
||||
WasteType.PACKAGES: "Packages Waste Pickup",
|
||||
WasteType.PAPER: "Paper Waste Pickup",
|
||||
WasteType.TREE: "Christmas Tree Pickup",
|
||||
WasteType.NON_RECYCLABLE: "Non-recyclable waste pickup",
|
||||
WasteType.ORGANIC: "Organic waste pickup",
|
||||
WasteType.PACKAGES: "Packages waste pickup",
|
||||
WasteType.PAPER: "Paper waste pickup",
|
||||
WasteType.TREE: "Christmas tree pickup",
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ class TwenteMilieuEntity(
|
|||
):
|
||||
"""Defines a Twente Milieu entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator[dict[WasteType, list[date]]],
|
||||
|
|
|
@ -27,7 +27,7 @@ async def test_waste_pickup_calendar(
|
|||
assert entry.unique_id == "12345"
|
||||
assert state.attributes[ATTR_ICON] == "mdi:delete-empty"
|
||||
assert state.attributes["all_day"] is True
|
||||
assert state.attributes["message"] == "Christmas Tree Pickup"
|
||||
assert state.attributes["message"] == "Christmas tree pickup"
|
||||
assert not state.attributes["location"]
|
||||
assert not state.attributes["description"]
|
||||
assert state.state == STATE_OFF
|
||||
|
@ -78,7 +78,7 @@ async def test_api_events(
|
|||
assert events[0] == {
|
||||
"start": {"date": "2022-01-06"},
|
||||
"end": {"date": "2022-01-06"},
|
||||
"summary": "Christmas Tree Pickup",
|
||||
"summary": "Christmas tree pickup",
|
||||
"description": None,
|
||||
"location": None,
|
||||
}
|
||||
|
|
|
@ -22,57 +22,72 @@ 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")
|
||||
state = hass.states.get("sensor.twente_milieu_christmas_tree_pickup")
|
||||
entry = entity_registry.async_get("sensor.twente_milieu_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_FRIENDLY_NAME)
|
||||
== "Twente Milieu 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")
|
||||
state = hass.states.get("sensor.twente_milieu_non_recyclable_waste_pickup")
|
||||
entry = entity_registry.async_get(
|
||||
"sensor.twente_milieu_non_recyclable_waste_pickup"
|
||||
)
|
||||
assert entry
|
||||
assert state
|
||||
assert entry.unique_id == "twentemilieu_12345_Non-recyclable"
|
||||
assert state.state == "2021-11-01"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Non-recyclable Waste Pickup"
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
== "Twente Milieu Non-recyclable waste pickup"
|
||||
)
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.DATE
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:delete-empty"
|
||||
assert ATTR_UNIT_OF_MEASUREMENT not in state.attributes
|
||||
|
||||
state = hass.states.get("sensor.organic_waste_pickup")
|
||||
entry = entity_registry.async_get("sensor.organic_waste_pickup")
|
||||
state = hass.states.get("sensor.twente_milieu_organic_waste_pickup")
|
||||
entry = entity_registry.async_get("sensor.twente_milieu_organic_waste_pickup")
|
||||
assert entry
|
||||
assert state
|
||||
assert entry.unique_id == "twentemilieu_12345_Organic"
|
||||
assert state.state == "2021-11-02"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Organic Waste Pickup"
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "Twente Milieu Organic waste pickup"
|
||||
)
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.DATE
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:delete-empty"
|
||||
assert ATTR_UNIT_OF_MEASUREMENT not in state.attributes
|
||||
|
||||
state = hass.states.get("sensor.packages_waste_pickup")
|
||||
entry = entity_registry.async_get("sensor.packages_waste_pickup")
|
||||
state = hass.states.get("sensor.twente_milieu_packages_waste_pickup")
|
||||
entry = entity_registry.async_get("sensor.twente_milieu_packages_waste_pickup")
|
||||
assert entry
|
||||
assert state
|
||||
assert entry.unique_id == "twentemilieu_12345_Plastic"
|
||||
assert state.state == "2021-11-03"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Packages Waste Pickup"
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
== "Twente Milieu Packages waste pickup"
|
||||
)
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.DATE
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:delete-empty"
|
||||
assert ATTR_UNIT_OF_MEASUREMENT not in state.attributes
|
||||
|
||||
state = hass.states.get("sensor.paper_waste_pickup")
|
||||
entry = entity_registry.async_get("sensor.paper_waste_pickup")
|
||||
state = hass.states.get("sensor.twente_milieu_paper_waste_pickup")
|
||||
entry = entity_registry.async_get("sensor.twente_milieu_paper_waste_pickup")
|
||||
assert entry
|
||||
assert state
|
||||
assert entry.unique_id == "twentemilieu_12345_Paper"
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Paper Waste Pickup"
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "Twente Milieu Paper waste pickup"
|
||||
)
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.DATE
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:delete-empty"
|
||||
assert ATTR_UNIT_OF_MEASUREMENT not in state.attributes
|
||||
|
|
Loading…
Add table
Reference in a new issue