|
13 | 13 | * + subscribes to openclaw_message_received events. |
14 | 14 | */ |
15 | 15 |
|
16 | | -const CARD_VERSION = "0.3.9"; |
| 16 | +const CARD_VERSION = "0.3.10"; |
17 | 17 |
|
18 | 18 | // Max time (ms) to show the thinking indicator before falling back to an error |
19 | 19 | const THINKING_TIMEOUT_MS = 120_000; |
@@ -94,6 +94,7 @@ class OpenClawChatCard extends HTMLElement { |
94 | 94 | this._assistAutoStopTimer = null; |
95 | 95 | this._lastAssistantEventSignature = null; |
96 | 96 | this._autoScrollPinned = true; |
| 97 | + this._lastHassRenderSignature = null; |
97 | 98 | } |
98 | 99 |
|
99 | 100 | // ── HA card interface ─────────────────────────────────────────────── |
@@ -126,12 +127,36 @@ class OpenClawChatCard extends HTMLElement { |
126 | 127 | set hass(hass) { |
127 | 128 | const firstSet = !this._hass; |
128 | 129 | this._hass = hass; |
| 130 | + const currentSignature = this._getHassRenderSignature(hass); |
129 | 131 | if (firstSet) { |
130 | 132 | this._subscribeToEvents(); |
131 | 133 | this._syncHistoryFromBackend(); |
132 | 134 | this._loadIntegrationSettings(); |
133 | 135 | } |
134 | | - this._render(); |
| 136 | + if (firstSet || currentSignature !== this._lastHassRenderSignature) { |
| 137 | + this._lastHassRenderSignature = currentSignature; |
| 138 | + this._render(); |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + _getHassRenderSignature(hass) { |
| 143 | + const states = hass?.states || {}; |
| 144 | + const stateEntries = Object.entries(states); |
| 145 | + |
| 146 | + const statusEntity = |
| 147 | + states["sensor.openclaw_status"] || |
| 148 | + stateEntries.find(([entityId]) => entityId.startsWith("sensor.openclaw_status"))?.[1] || |
| 149 | + null; |
| 150 | + |
| 151 | + const binaryEntity = |
| 152 | + states["binary_sensor.openclaw_connected"] || |
| 153 | + stateEntries.find(([entityId]) => entityId.startsWith("binary_sensor.openclaw_connected"))?.[1] || |
| 154 | + null; |
| 155 | + |
| 156 | + const status = String(statusEntity?.state || "").toLowerCase(); |
| 157 | + const connectedState = String(binaryEntity?.state || "").toLowerCase(); |
| 158 | + |
| 159 | + return `${status}|${connectedState}`; |
135 | 160 | } |
136 | 161 |
|
137 | 162 | _getGatewayConnectionState() { |
|
0 commit comments