7 Commits

Author SHA1 Message Date
Clawd
5cdc4e2ce2 Fix stale data after HA outage recovery
Some checks failed
Release Drafter / update_release_draft (push) Failing after 5s
Two bugs caused the module to show outdated data permanently after HA
came back online:

1. refreshTimer was only checked at section level, but config sets it at
   the module config level. The setInterval never started, so there was
   no periodic re-render fallback when the WebSocket died.

2. _closeCircuit replayed queued templates but never reconnected the
   WebSocket. Without WS, no state_changed events fire, so the only
   render path was the (broken) refreshTimer.

Also fixes a race condition in _healthCheck where breaker.state was
briefly set to 'closed' before calling _openCircuit on failure. Now
uses 'half-open' state instead.
2026-03-01 08:59:15 +00:00
Clawd
de03a33138 Add circuit breaker for HA connectivity failures
Some checks failed
Release Drafter / update_release_draft (push) Failing after 5s
When Home Assistant becomes unreachable (WiFi dropout, HA restart, etc.),
the module now:
- Detects connectivity errors (ENETUNREACH, timeout, etc.)
- Opens a circuit breaker that stops ALL template evaluations immediately
- Runs a single coalesced health check with exponential backoff (15s→300s)
- Queues pending evaluations and replays them when HA comes back
- Suppresses error log spam while circuit is open

Previously, each of the 11 sections would independently fail + retry,
flooding the event loop with 30+ error callbacks in the same millisecond
and freezing Electron's renderer.

Fixes repeated MagicMirror freezes during transient network outages.
2026-02-27 15:16:29 +00:00
Clawd
8831ee9e13 Remove debug log spam from hot path entirely
Some checks failed
Release Drafter / update_release_draft (push) Failing after 4s
The conditional config.debuglogging checks were not working reliably
in node_helper context. Removed debug logging from onStateChangedEvent
entirely (it fires on every entity state change - multiple times per
second for power sensors). WS disconnect promoted to info level since
it's actually useful.
2026-02-23 20:11:51 +00:00
Clawd
a2955ceab4 Fix debug log spam by gating debug logs with config.debuglogging
Some checks failed
Release Drafter / update_release_draft (push) Failing after 4s
- Added config.debuglogging check to 'Found listening connection' debug log
- Added config.debuglogging check to 'Hass WS Disconnected' debug log
- Prevents log spam when debuglogging is disabled (default)
- Fixes issue causing multi-GB log files from frequent state change events
2026-02-23 19:54:06 +00:00
Clawd
9ba31cbafe Fix template evaluation timeouts and add retry logic
Some checks failed
Release Drafter / update_release_draft (push) Failing after 4s
- Add 10 second timeout to template evaluation HTTP calls
- Add retry logic that schedules retry after 30 seconds on failure
- Maintains existing error handling while preventing silent failures
- Fixes issue where template errors cause data to stay stale until next WebSocket event
2026-02-23 18:01:36 +00:00
Brian Towles
4faf5c938b Fix for #6 reconnect issue. 2022-05-28 10:01:28 -05:00
btowles
392ef6ccc0 Initial Commit 2021-08-16 02:36:15 +00:00