fix: Log problems to the console as warnings (once) (#2414)

This commit is contained in:
Dermot Duffy
2026-06-30 17:45:12 -07:00
committed by dermotduffy
parent 3f5a35c7f6
commit 16ca8d79d2
3 changed files with 82 additions and 3 deletions
+13
View File
@@ -16,6 +16,7 @@ import {
export class ProblemManager {
private _api: CardProblemAPI;
private _problems = new Map<ProblemKey, Problem>();
private _loggedKeys = new Set<ProblemKey>();
constructor(api: CardProblemAPI) {
this._api = api;
@@ -46,6 +47,7 @@ export class ProblemManager {
public async detectStatic(hass: HomeAssistant): Promise<void> {
for (const problem of this._problems.values()) {
await problem.detectStatic?.(hass);
this._logIfNew(problem);
}
this._api.getCardElementManager().update();
}
@@ -122,9 +124,20 @@ export class ProblemManager {
const hadResult = problem.hasResult();
problem.detectDynamic?.(context);
stateChanged ||= problem.hasResult() !== hadResult;
this._logIfNew(problem);
}
if (stateChanged) {
this._api.getCardElementManager().update();
}
}
private _logIfNew(problem: Problem): void {
if (problem.hasResult() && !this._loggedKeys.has(problem.key)) {
this._loggedKeys.add(problem.key);
const text = problem.getResult()?.notification.text;
if (text) {
console.warn(`Advanced Camera Card: ${text}`);
}
}
}
}
+3 -3
View File
@@ -826,12 +826,12 @@
"troubleshooting_guide": "Troubleshooting guide",
"config_upgrade": {
"heading": "Configuration upgrade available",
"text": "A configuration upgrade is available. To upgrade, edit this card (Dashboard pencil icon \u2192 Three-dot menu \u2192 Edit) and click the 'Automatic Upgrade' button in the card editor."
"text": "A configuration upgrade is available. To upgrade, edit this card (Dashboard pencil icon \u2192 Three-dot menu \u2192 Edit) and click the 'Automatic Upgrade' button in the card editor"
},
"legacy_resource": {
"heading": "Legacy dashboard resource detected",
"text_both": "The legacy 'frigate-hass-card.js' resource is still registered, please either manually remove it or click the delete icon to automatically remove it. It will be removed in a future release.",
"text_only_legacy": "The legacy 'frigate-hass-card.js' resource must be replaced with 'advanced-camera-card.js'. It will be removed in a future release.",
"text_both": "The legacy 'frigate-hass-card.js' resource is still registered, please either manually remove it or click the delete icon to automatically remove it. It will be removed in a future release",
"text_only_legacy": "The legacy 'frigate-hass-card.js' resource must be replaced with 'advanced-camera-card.js'. It will be removed in a future release",
"remove": "Remove legacy resource"
},
"stream_not_loading": {