mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix broken postnl sensor (#28794)
* fix broken postnl sensor * make sure shipment list is not growing indefinitely
This commit is contained in:
parent
afbd966ba6
commit
87b13ee732
@ -3,7 +3,7 @@
|
||||
"name": "Postnl",
|
||||
"documentation": "https://www.home-assistant.io/integrations/postnl",
|
||||
"requirements": [
|
||||
"postnl_api==1.0.2"
|
||||
"postnl_api==1.2.2"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": []
|
||||
|
@ -58,7 +58,7 @@ class PostNLSensor(Entity):
|
||||
def __init__(self, api, name):
|
||||
"""Initialize the PostNL sensor."""
|
||||
self._name = name
|
||||
self._attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
self._attributes = {ATTR_ATTRIBUTION: ATTRIBUTION, "shipments": []}
|
||||
self._state = None
|
||||
self._api = api
|
||||
|
||||
@ -90,6 +90,11 @@ class PostNLSensor(Entity):
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
"""Update device state."""
|
||||
shipments = self._api.get_relevant_shipments()
|
||||
self._attributes["shipments"] = shipments
|
||||
shipments = self._api.get_relevant_deliveries()
|
||||
|
||||
self._attributes["shipments"] = []
|
||||
|
||||
for shipment in shipments:
|
||||
self._attributes["shipments"].append(vars(shipment))
|
||||
|
||||
self._state = len(shipments)
|
||||
|
@ -999,7 +999,7 @@ pmsensor==0.4
|
||||
pocketcasts==0.1
|
||||
|
||||
# homeassistant.components.postnl
|
||||
postnl_api==1.0.2
|
||||
postnl_api==1.2.2
|
||||
|
||||
# homeassistant.components.reddit
|
||||
praw==6.4.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user