You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: add Home Assistant Event entity for command errors
ClosesSAIC-iSmart-API#272. When a command to the vehicle fails, a JSON event is now
published to the command/error topic so Home Assistant users can build
automations around command failures.
Changes:
- Add _publish_event() to HA discovery base for MQTT Event entities
- Register a "Command error" diagnostic event entity in discovery
- Publish error events from all failure paths in VehicleCommandHandler
- Wrap error event publishing in try-except to prevent masking original errors
- Cover the "no handler found" path with error events too
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: consolidate command failure reporting into single helper
Replace repeated publish_str + LOG + publish_command_error calls across
all except blocks with a single __report_command_failure method.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: harden __report_command_failure against publish errors
- Log the original error before attempting any MQTT publish
- Wrap both publish_str and publish_json in try-except
- Make exc optional so "no handler found" uses LOG.error (no traceback)
- Use safe "unexpected error" detail for the catch-all exception path
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add tests for command error event publishing
Cover all error paths in VehicleCommandHandler:
- Success path (no error event)
- No handler found (error event without traceback)
- MqttGatewayException, SaicApiException, unexpected Exception
- SaicLogoutException: relogin success/failure, retry failure
- Resilience: publish_str/publish_json failures don't propagate
- Event payload structure and topic verification
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: rewrite tests to pass mypy strict checks
Restructure tests to avoid accessing private name-mangled attributes
and asserting on typed Publisher methods. Drive exceptions through
saic_api mocks instead of patching internal command handlers.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments