feat: add HA Event entity for vehicle messages#434
Merged
nanomad merged 5 commits intoSAIC-iSmart-API:developfrom Mar 14, 2026
Merged
feat: add HA Event entity for vehicle messages#434nanomad merged 5 commits intoSAIC-iSmart-API:developfrom
nanomad merged 5 commits intoSAIC-iSmart-API:developfrom
Conversation
Publishes a vehicle_message event to Home Assistant whenever a new message arrives from the car (maintenance alerts, security notifications, etc.). The event includes title, content, message_type, sender, and vin attributes for use in automations. Deduplication is handled by the existing MessagePublisher guard that only processes messages with a newer timestamp than the last seen. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Document best-effort intent with comment - Upgrade LOG.warning to LOG.exception with message ID and VIN context - Add resilience test: event publish failure doesn't break processing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HA Event entities show "Unknown" when they receive a retained message on connect because they cannot determine when the event occurred. Add a retain parameter to publish_json (default True for backward compat) and thread it through VehicleDataPublisher._publish. Both command_error and vehicle_message events now publish with retain=False. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The SAIC API returns message timestamps as naive datetimes, but last_message_ts is initialized as UTC-aware. Comparing them raises TypeError. Add _ensure_aware() to normalize naive datetimes to UTC before comparison in both MessageHandler and MessagePublisher. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract ensure_datetime_aware to utils.py, remove duplicates - Apply ensure_datetime_aware to max()/min() lambdas in message handler - Thread retain parameter through _transform_and_publish for consistency - Use LOG.exception consistently for event publish failures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
event.vehicle_message) that fires when a new message arrives from the cartitle,content,message_type,sender, andvinfor use in HA automationsMessagePublishertimestamp guard — only genuinely new messages fire the eventinfo/lastMessage/*sensorsTest plan
ruff check,poetry run mypy,pytest— all pass (161 tests)🤖 Generated with Claude Code