mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Upgrade twentemilieu to 0.4.2 (#59599)
This commit is contained in:
parent
9d674af566
commit
c70f06be48
@ -53,7 +53,7 @@ class TwenteMilieuFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
twentemilieu = TwenteMilieu(
|
twentemilieu = TwenteMilieu(
|
||||||
post_code=user_input[CONF_POST_CODE],
|
post_code=user_input[CONF_POST_CODE],
|
||||||
house_number=user_input[CONF_HOUSE_NUMBER],
|
house_number=user_input[CONF_HOUSE_NUMBER],
|
||||||
house_letter=user_input.get(CONF_HOUSE_LETTER),
|
house_letter=user_input.get(CONF_HOUSE_LETTER, ""),
|
||||||
session=session,
|
session=session,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Twente Milieu",
|
"name": "Twente Milieu",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/twentemilieu",
|
"documentation": "https://www.home-assistant.io/integrations/twentemilieu",
|
||||||
"requirements": ["twentemilieu==0.3.0"],
|
"requirements": ["twentemilieu==0.4.2"],
|
||||||
"codeowners": ["@frenck"],
|
"codeowners": ["@frenck"],
|
||||||
"iot_class": "cloud_polling"
|
"iot_class": "cloud_polling"
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
"""Support for Twente Milieu sensors."""
|
"""Support for Twente Milieu sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from twentemilieu import (
|
from dataclasses import dataclass
|
||||||
WASTE_TYPE_NON_RECYCLABLE,
|
|
||||||
WASTE_TYPE_ORGANIC,
|
from twentemilieu import TwenteMilieu, TwenteMilieuConnectionError, WasteType
|
||||||
WASTE_TYPE_PAPER,
|
|
||||||
WASTE_TYPE_PLASTIC,
|
|
||||||
TwenteMilieu,
|
|
||||||
TwenteMilieuConnectionError,
|
|
||||||
)
|
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -23,28 +18,47 @@ from .const import DATA_UPDATE, DOMAIN
|
|||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
SENSORS: tuple[SensorEntityDescription, ...] = (
|
|
||||||
SensorEntityDescription(
|
@dataclass
|
||||||
key=WASTE_TYPE_NON_RECYCLABLE,
|
class TwenteMilieuSensorDescriptionMixin:
|
||||||
name=f"{WASTE_TYPE_NON_RECYCLABLE} Waste Pickup",
|
"""Define an entity description mixin."""
|
||||||
|
|
||||||
|
waste_type: WasteType
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class TwenteMilieuSensorDescription(
|
||||||
|
SensorEntityDescription, TwenteMilieuSensorDescriptionMixin
|
||||||
|
):
|
||||||
|
"""Describe an Ambient PWS binary sensor."""
|
||||||
|
|
||||||
|
|
||||||
|
SENSORS: tuple[TwenteMilieuSensorDescription, ...] = (
|
||||||
|
TwenteMilieuSensorDescription(
|
||||||
|
key="Non-recyclable",
|
||||||
|
waste_type=WasteType.NON_RECYCLABLE,
|
||||||
|
name="Non-recyclable Waste Pickup",
|
||||||
icon="mdi:delete-empty",
|
icon="mdi:delete-empty",
|
||||||
device_class=DEVICE_CLASS_DATE,
|
device_class=DEVICE_CLASS_DATE,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
TwenteMilieuSensorDescription(
|
||||||
key=WASTE_TYPE_ORGANIC,
|
key="Organic",
|
||||||
name=f"{WASTE_TYPE_ORGANIC} Waste Pickup",
|
waste_type=WasteType.ORGANIC,
|
||||||
|
name="Organic Waste Pickup",
|
||||||
icon="mdi:delete-empty",
|
icon="mdi:delete-empty",
|
||||||
device_class=DEVICE_CLASS_DATE,
|
device_class=DEVICE_CLASS_DATE,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
TwenteMilieuSensorDescription(
|
||||||
key=WASTE_TYPE_PAPER,
|
key="Paper",
|
||||||
name=f"{WASTE_TYPE_PAPER} Waste Pickup",
|
waste_type=WasteType.PAPER,
|
||||||
|
name="Paper Waste Pickup",
|
||||||
icon="mdi:delete-empty",
|
icon="mdi:delete-empty",
|
||||||
device_class=DEVICE_CLASS_DATE,
|
device_class=DEVICE_CLASS_DATE,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
TwenteMilieuSensorDescription(
|
||||||
key=WASTE_TYPE_PLASTIC,
|
key="Plastic",
|
||||||
name=f"{WASTE_TYPE_PLASTIC} Waste Pickup",
|
waste_type=WasteType.PACKAGES,
|
||||||
|
name="Packages Waste Pickup",
|
||||||
icon="mdi:delete-empty",
|
icon="mdi:delete-empty",
|
||||||
device_class=DEVICE_CLASS_DATE,
|
device_class=DEVICE_CLASS_DATE,
|
||||||
),
|
),
|
||||||
@ -76,13 +90,14 @@ async def async_setup_entry(
|
|||||||
class TwenteMilieuSensor(SensorEntity):
|
class TwenteMilieuSensor(SensorEntity):
|
||||||
"""Defines a Twente Milieu sensor."""
|
"""Defines a Twente Milieu sensor."""
|
||||||
|
|
||||||
|
entity_description: TwenteMilieuSensorDescription
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
twentemilieu: TwenteMilieu,
|
twentemilieu: TwenteMilieu,
|
||||||
unique_id: str,
|
unique_id: str,
|
||||||
description: SensorEntityDescription,
|
description: TwenteMilieuSensorDescription,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the Twente Milieu entity."""
|
"""Initialize the Twente Milieu entity."""
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
@ -104,6 +119,7 @@ class TwenteMilieuSensor(SensorEntity):
|
|||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update Twente Milieu entity."""
|
"""Update Twente Milieu entity."""
|
||||||
next_pickup = await self._twentemilieu.next_pickup(self.entity_description.key)
|
pickups = await self._twentemilieu.update()
|
||||||
if next_pickup is not None:
|
self._attr_native_value = None
|
||||||
self._attr_native_value = next_pickup.date().isoformat()
|
if pickup := pickups.get(self.entity_description.waste_type):
|
||||||
|
self._attr_native_value = pickup.isoformat()
|
||||||
|
@ -2332,7 +2332,7 @@ transmissionrpc==0.11
|
|||||||
tuya-iot-py-sdk==0.6.3
|
tuya-iot-py-sdk==0.6.3
|
||||||
|
|
||||||
# homeassistant.components.twentemilieu
|
# homeassistant.components.twentemilieu
|
||||||
twentemilieu==0.3.0
|
twentemilieu==0.4.2
|
||||||
|
|
||||||
# homeassistant.components.twilio
|
# homeassistant.components.twilio
|
||||||
twilio==6.32.0
|
twilio==6.32.0
|
||||||
|
@ -1354,7 +1354,7 @@ transmissionrpc==0.11
|
|||||||
tuya-iot-py-sdk==0.6.3
|
tuya-iot-py-sdk==0.6.3
|
||||||
|
|
||||||
# homeassistant.components.twentemilieu
|
# homeassistant.components.twentemilieu
|
||||||
twentemilieu==0.3.0
|
twentemilieu==0.4.2
|
||||||
|
|
||||||
# homeassistant.components.twilio
|
# homeassistant.components.twilio
|
||||||
twilio==6.32.0
|
twilio==6.32.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user