Skip to content

fix: timezone-aware datetime for payment confirmation button#8

Merged
CodekExplor merged 1 commit intomainfrom
copilot/fix-invalid-datetime-error
Apr 14, 2026
Merged

fix: timezone-aware datetime for payment confirmation button#8
CodekExplor merged 1 commit intomainfrom
copilot/fix-invalid-datetime-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Pressing "Potwierdź płatność" failed with Invalid datetime: missing timezone information because datetime.now() produces a naive datetime, which HA's DateTimeEntity rejects.

Changes

  • coordinator.py — swap datetime.now() for dt_util.now() (homeassistant.util.dt), which always returns a timezone-aware datetime respecting HA's configured timezone:

    # before
    self._payment_confirmed_date = datetime.now().isoformat()
    # after
    self._payment_confirmed_date = dt_util.now().isoformat()
  • datetime.py — harden native_value to handle legacy naive ISO strings already persisted in storage by attaching UTC if tzinfo is absent:

    dt = datetime.fromisoformat(raw)
    if dt.tzinfo is None:
        dt = dt.replace(tzinfo=timezone.utc)
    return dt

@CodekExplor CodekExplor marked this pull request as ready for review April 14, 2026 10:08
@CodekExplor CodekExplor merged commit 0e0c1c6 into main Apr 14, 2026
1 check failed
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