Skip to content

feat: Expose delivery window attributes (date_expected_end, timestamps)#73

Open
robbybarnes wants to merge 3 commits intojmdevita:mainfrom
robbybarnes:feature/expose-delivery-window-attributes
Open

feat: Expose delivery window attributes (date_expected_end, timestamps)#73
robbybarnes wants to merge 3 commits intojmdevita:mainfrom
robbybarnes:feature/expose-delivery-window-attributes

Conversation

@robbybarnes
Copy link

Summary

Exposes additional delivery timing attributes from the ParcelApp API that provide more precise delivery window information.

Motivation

The API returns delivery window data that wasn't being exposed:

  • date_expected_end - End of delivery window (when carriers give a range)
  • timestamp_expected - Unix timestamp of expected delivery
  • timestamp_expected_end - Unix timestamp of delivery window end

This data is useful for automations that need precise timing, such as:

  • Triggering alerts when a package is expected within the hour
  • Creating calendar events with proper duration
  • More accurate "arriving today" notifications

Changes

  • Added date_expected_end, timestamp_expected, timestamp_expected_end to the Shipment class
  • Updated EMPTY_ATTRIBUTES to include new fields
  • Modified ActiveShipment sensor to parse and expose these attributes
  • Timestamps are converted from Unix epoch to Python datetime objects
  • Updated tests to include new attributes

New Attributes

Attribute Type Description
date_expected_end date or None End date of delivery window
timestamp_expected datetime or None Precise expected delivery time
timestamp_expected_end datetime or None End of delivery time window

Testing

  • All tests pass (11/11)
  • Test fixtures updated to validate new attributes

robbybarnes and others added 2 commits January 20, 2026 18:13
Adds three new attributes to the ActiveShipment sensor to expose delivery
window information when provided by carriers:

- date_expected_end: End of delivery window (for carriers that provide time ranges)
- timestamp_expected: Epoch timestamp for expected delivery (more precise, includes timezone)
- timestamp_expected_end: End of delivery window as epoch timestamp

These attributes are already parsed from the API response and stored in the
Shipment class but were not previously exposed to Home Assistant. This enables
users to create more precise automations based on delivery windows.

Also updates EMPTY_ATTRIBUTES in const.py for consistency.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update test assertions to include date_expected_end, timestamp_expected,
and timestamp_expected_end attributes that were added to EMPTY_ATTRIBUTES.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@PineappleEmperor PineappleEmperor self-requested a review January 24, 2026 12:44
Copy link
Collaborator

@PineappleEmperor PineappleEmperor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small updates needed before it's good to go I think, namely add a proper test and if the recent sensor can also be updated.

'full_description': 'Wireless Mouse Set',
'tracking_number': '8217400125612976',
'date_expected': tomorrow,
'date_expected_end': None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ideally here we'd have a test that provides a value other than None. Can you add an update to the recent.json fixture to provide this?

"full_description": description,
"tracking_number": tracking_number,
"date_expected": date_expected,
"date_expected_end": next_traceable_shipment.date_expected_end,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this also be added to the Recent sensor?

Per maintainer feedback:
- Added date_expected_end, timestamp_expected, timestamp_expected_end
  attributes to RecentShipment sensor (matching ActiveShipment)
- Updated recent.json fixture with actual delivery window values
- Updated tests to verify non-None delivery window values
- Added dedicated test_delivery_window_attributes test
- Fixed TypeError handling for timestamp parsing (caught by CodeRabbit)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants