feat(core): track setup status of components on start/reload#1312
feat(core): track setup status of components on start/reload#1312roflcoopter merged 1 commit intodevfrom
Conversation
✅ Deploy Preview for viseron canceled.
|
There was a problem hiding this comment.
Pull request overview
Adds structured tracking of component lifecycle/setup status (including errors) and exposes that status for frontend consumption, while enhancing reload-time validation to return structured errors.
Changes:
- Introduces
ComponentState,ComponentError*, and component setup-status events/error accumulation inviseron.components. - Updates config reload validation to return
ComponentErrorobjects and clear/propagate validation errors onto existing components. - Adds a core API (
Viseron.get_setup_status) to expose component (and attached domain) setup status; updates tests accordingly.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
viseron/components/__init__.py |
Adds component state machine, structured errors, status event dispatching, and new validation result type. |
viseron/reload.py |
Switches reload validation to structured errors and clears stale validation errors on reload start. |
viseron/domains/__init__.py |
Propagates domain setup failures into the owning component’s error list. |
viseron/const.py |
Adds a new event topic for component setup status changes. |
viseron/__init__.py |
Exposes get_setup_status() for frontend consumption of setup status. |
tests/test_reload.py |
Updates reload validation/reload-config tests for structured errors and new return types. |
tests/components/test__init__.py |
Adds/updates tests for component state transitions and error tracking. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| EventComponentSetupStatusData( | ||
| component=self._name, | ||
| state=self._state.value, | ||
| error=self._errors[-1].message if self._errors else None, | ||
| validation_error=self._validation_error, |
There was a problem hiding this comment.
_dispatch_status_event() reads self._errors without holding _errors_lock (self._errors[-1]). Since errors can be appended from other threads (eg, domain setup threads), this can race and produce inconsistent/incorrect event payloads. Consider taking a locked snapshot (or using the errors property) before building the event data.
2f5bff7 to
b147429
Compare
Store and track setup status of components/domains to later be consumed by the frontend