mirror of
https://github.com/xiaoshi930/xiaoshi-pad-card.git
synced 2025-11-29 00:59:42 +00:00
Update xiaoshi-device-consumables-card.js
This commit is contained in:
@@ -74,7 +74,6 @@ class XiaoshiConsumablesCardEditor extends LitElement {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
cursor: pointer;
|
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,6 +451,8 @@ class XiaoshiConsumablesCardEditor extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_entityChanged(e) {
|
_entityChanged(e) {
|
||||||
|
|
||||||
|
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
if (!value && name !== 'theme' && name !== 'width' ) return;
|
if (!value && name !== 'theme' && name !== 'width' ) return;
|
||||||
|
|
||||||
@@ -1265,6 +1266,15 @@ class XiaoshiConsumablesCard extends LitElement {
|
|||||||
const warningCount = this._oilPriceData.filter(consumablesData => {
|
const warningCount = this._oilPriceData.filter(consumablesData => {
|
||||||
let isWarning = false;
|
let isWarning = false;
|
||||||
|
|
||||||
|
// 对于 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 (consumablesData.warning_threshold && consumablesData.warning_threshold.trim() !== '') {
|
if (consumablesData.warning_threshold && consumablesData.warning_threshold.trim() !== '') {
|
||||||
isWarning = this._evaluateWarningCondition(consumablesData.value, consumablesData.warning_threshold);
|
isWarning = this._evaluateWarningCondition(consumablesData.value, consumablesData.warning_threshold);
|
||||||
} else {
|
} else {
|
||||||
@@ -1272,6 +1282,7 @@ class XiaoshiConsumablesCard extends LitElement {
|
|||||||
isWarning = this._evaluateWarningCondition(consumablesData.value, this.config.global_warning);
|
isWarning = this._evaluateWarningCondition(consumablesData.value, this.config.global_warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return isWarning;
|
return isWarning;
|
||||||
}).length;
|
}).length;
|
||||||
|
|||||||
Reference in New Issue
Block a user