fix: 17track package summary status is not updated when there are no more packages in that summary (#64421)
* 17track package status is not updated when there are no packages * 17track package status is not updated when there are no packages * 17track package status is not updated when there are no packagespull/64514/head
parent
24e24a5157
commit
6176bb954c
|
@ -150,8 +150,9 @@ class SeventeenTrackSummarySensor(SensorEntity):
|
|||
}
|
||||
)
|
||||
|
||||
if package_data:
|
||||
self._attr_extra_state_attributes[ATTR_PACKAGES] = package_data
|
||||
self._attr_extra_state_attributes[ATTR_PACKAGES] = (
|
||||
package_data if package_data else None
|
||||
)
|
||||
|
||||
self._state = self._data.summary.get(self._status)
|
||||
|
||||
|
|
|
@ -379,12 +379,37 @@ async def test_becomes_delivered_not_shown_notification(hass):
|
|||
|
||||
async def test_summary_correctly_updated(hass):
|
||||
"""Ensure summary entities are not duplicated."""
|
||||
package = Package(
|
||||
tracking_number="456",
|
||||
destination_country=206,
|
||||
friendly_name="friendly name 1",
|
||||
info_text="info text 1",
|
||||
location="location 1",
|
||||
timestamp="2020-08-10 10:32",
|
||||
origin_country=206,
|
||||
package_type=2,
|
||||
status=30,
|
||||
)
|
||||
ProfileMock.package_list = [package]
|
||||
|
||||
await _setup_seventeentrack(hass, summary_data=DEFAULT_SUMMARY)
|
||||
|
||||
assert len(hass.states.async_entity_ids()) == 7
|
||||
assert len(hass.states.async_entity_ids()) == 8
|
||||
for state in hass.states.async_all():
|
||||
if state.entity_id == "sensor.seventeentrack_package_456":
|
||||
break
|
||||
assert state.state == "0"
|
||||
|
||||
assert (
|
||||
len(
|
||||
hass.states.get(
|
||||
"sensor.seventeentrack_packages_ready_to_be_picked_up"
|
||||
).attributes["packages"]
|
||||
)
|
||||
== 1
|
||||
)
|
||||
|
||||
ProfileMock.package_list = []
|
||||
ProfileMock.summary_data = NEW_SUMMARY_DATA
|
||||
|
||||
await _goto_future(hass)
|
||||
|
@ -393,6 +418,13 @@ async def test_summary_correctly_updated(hass):
|
|||
for state in hass.states.async_all():
|
||||
assert state.state == "1"
|
||||
|
||||
assert (
|
||||
hass.states.get(
|
||||
"sensor.seventeentrack_packages_ready_to_be_picked_up"
|
||||
).attributes["packages"]
|
||||
is None
|
||||
)
|
||||
|
||||
|
||||
async def test_utc_timestamp(hass):
|
||||
"""Ensure package timestamp is converted correctly from HA-defined time zone to UTC."""
|
||||
|
|
Loading…
Reference in New Issue