From 59268a91f80d28cd396e8c301d2d65a136798c7d Mon Sep 17 00:00:00 2001 From: xiaoshi <115949669+xiaoshi930@users.noreply.github.com> Date: Thu, 27 Nov 2025 15:45:29 +0800 Subject: [PATCH] Update xiaoshi-device-consumables-card.js --- xiaoshi-device-consumables-card.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/xiaoshi-device-consumables-card.js b/xiaoshi-device-consumables-card.js index 57e2b44..aff0afd 100644 --- a/xiaoshi-device-consumables-card.js +++ b/xiaoshi-device-consumables-card.js @@ -74,7 +74,6 @@ class XiaoshiConsumablesCardEditor extends LitElement { align-items: center; justify-content: space-between; padding: 8px 12px; - cursor: pointer; border-bottom: 1px solid #eee; } @@ -452,6 +451,8 @@ class XiaoshiConsumablesCardEditor extends LitElement { } _entityChanged(e) { + + const { name, value } = e.target; if (!value && name !== 'theme' && name !== 'width' ) return; @@ -1265,11 +1266,21 @@ class XiaoshiConsumablesCard extends LitElement { const warningCount = this._oilPriceData.filter(consumablesData => { let isWarning = false; - if (consumablesData.warning_threshold && consumablesData.warning_threshold.trim() !== '') { - isWarning = this._evaluateWarningCondition(consumablesData.value, consumablesData.warning_threshold); + // 对于 binary_sensor 和 event,使用默认预警逻辑 + if (consumablesData.entity_id.startsWith('binary_sensor.') && !consumablesData.warning_threshold) { + // binary_sensor: "缺少"状态时预警 + isWarning = consumablesData.value === '缺少'; + } else if (consumablesData.entity_id.startsWith('event.') && !consumablesData.warning_threshold) { + // event: "低电量"状态时预警 + isWarning = consumablesData.value === '低电量'; } else { - if (this.config.global_warning && this.config.global_warning.trim() !== '') { - isWarning = this._evaluateWarningCondition(consumablesData.value, this.config.global_warning); + // 使用配置的预警条件 + if (consumablesData.warning_threshold && consumablesData.warning_threshold.trim() !== '') { + isWarning = this._evaluateWarningCondition(consumablesData.value, consumablesData.warning_threshold); + } else { + if (this.config.global_warning && this.config.global_warning.trim() !== '') { + isWarning = this._evaluateWarningCondition(consumablesData.value, this.config.global_warning); + } } }