mirror of
https://github.com/xiaoshi930/xiaoshi-pad-card.git
synced 2025-11-28 16:49:42 +00:00
Compare commits
34 Commits
v0.0.6
...
da16f27cf2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da16f27cf2 | ||
|
|
df6a678043 | ||
|
|
82930f4e41 | ||
|
|
4a2ffb628d | ||
|
|
3d5f6028c2 | ||
|
|
765b0a1367 | ||
|
|
df66608d7f | ||
|
|
6ed3bca2cc | ||
|
|
f1d0b52bd7 | ||
|
|
528eaf1cd1 | ||
|
|
59268a91f8 | ||
|
|
f768186379 | ||
|
|
2371475eca | ||
|
|
befca5ece5 | ||
|
|
24848db29b | ||
|
|
be232dc056 | ||
|
|
96fb548262 | ||
|
|
16831e5102 | ||
|
|
b05f7de548 | ||
|
|
d8d4389549 | ||
|
|
bca500c945 | ||
|
|
5f36835adb | ||
|
|
05d083c259 | ||
|
|
3738b0b092 | ||
|
|
87e9e68b79 | ||
|
|
7ddd378b9a | ||
|
|
23b6e5b8a3 | ||
|
|
4067518d0d | ||
|
|
53e06aacf7 | ||
|
|
9a59c2bb90 | ||
|
|
0ae5851361 | ||
|
|
a17033c0f0 | ||
|
|
44a1d81265 | ||
|
|
2de0668d37 |
54
README.md
54
README.md
@@ -24,31 +24,26 @@ max: 80 # 当前地区最大值
|
||||
mode: 湿度 # 【温度】或者【湿度】
|
||||
~~~
|
||||
|
||||
## 功能2:HA版本更新卡(手机平板端通用)
|
||||
## 功能2:HA信息卡(手机平板端通用)
|
||||
**引用示例**
|
||||
~~~
|
||||
type: custom:xiaoshi-update-card
|
||||
width: 100p%
|
||||
width: 100%
|
||||
skip_updates: false #是否包含已跳过的更新
|
||||
theme: on
|
||||
~~~
|
||||
|
||||
## 功能3:HA离线设备卡(手机平板端通用)
|
||||
**引用示例**
|
||||
~~~
|
||||
type: custom:xiaoshi-offline-card
|
||||
width: 320px
|
||||
exclude_devices:
|
||||
- *设备*
|
||||
exclude_entities:
|
||||
- *shiti*
|
||||
~~~
|
||||
|
||||
## 功能4:电话信息余额卡(手机平板端通用)
|
||||
## 功能3:电话信息余额卡(手机平板端通用)
|
||||
**引用示例**
|
||||
~~~
|
||||
type: custom:xiaoshi-balance-card
|
||||
name: 电话余额信息
|
||||
width: 350px
|
||||
width: 100%
|
||||
theme: on
|
||||
entities:
|
||||
- entity_id: sensor.999
|
||||
attribute: null
|
||||
@@ -65,3 +60,40 @@ entities:
|
||||
unit_of_measurement: ""
|
||||
warning: "99"
|
||||
~~~
|
||||
|
||||
## 功能4:待办事项卡(手机平板端通用)
|
||||
**引用示例**
|
||||
~~~
|
||||
type: custom:xiaoshi-todo-card
|
||||
width: 100%
|
||||
theme: on
|
||||
entities:
|
||||
- todo.kuai_di
|
||||
- todo.ji_shi_ben
|
||||
~~~
|
||||
|
||||
## 功能5:耗材信息卡片(手机平板端通用)
|
||||
**引用示例**
|
||||
~~~
|
||||
type: custom:xiaoshi-consumables-card
|
||||
width: 100%
|
||||
global_warning: <8
|
||||
columns: "2"
|
||||
entities:
|
||||
- entity_id: input_text.aaa
|
||||
overrides:
|
||||
name: 奥斯卡德拉萨达实打实实打实
|
||||
unit_of_measurement: "%"
|
||||
warning: <10
|
||||
conversion: "*2"
|
||||
icon: ""
|
||||
- entity_id: input_text.aaa1
|
||||
- entity_id: input_text.aaa2
|
||||
- entity_id: input_text.aaa3
|
||||
- entity_id: input_text.aaa4
|
||||
- entity_id: input_text.aaa5
|
||||
- entity_id: input_text.aaa6
|
||||
- entity_id: input_text.aaa7
|
||||
~~~
|
||||
|
||||
|
||||
|
||||
@@ -236,7 +236,20 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label>全局预警条件:当任一实体满足此条件时触发预警</label>
|
||||
<input
|
||||
type="text"
|
||||
@change=${this._entityChanged}
|
||||
.value=${this.config.global_warning || ''}
|
||||
name="global_warning"
|
||||
placeholder="如: >10, <=5, ==on, ==off, =='hello world'"
|
||||
/>
|
||||
<div class="help-text">
|
||||
全局预警条件:当任一实体满足此条件时,该实体显示为红色预警状态<br>
|
||||
优先级:明细预警 > 全局预警 > 无预警
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>主题</label>
|
||||
@@ -308,24 +321,6 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
||||
class="attribute-input"
|
||||
/>
|
||||
|
||||
<div class="override-config">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="override-checkbox"
|
||||
@change=${(e) => this._updateEntityOverride(index, 'name', e.target.checked)}
|
||||
.checked=${entityConfig.overrides?.name !== undefined}
|
||||
/>
|
||||
<span class="override-label">名称:</span>
|
||||
<input
|
||||
type="text"
|
||||
class="override-input"
|
||||
@change=${(e) => this._updateEntityOverrideValue(index, 'name', e.target.value)}
|
||||
.value=${entityConfig.overrides?.name || ''}
|
||||
placeholder="自定义名称"
|
||||
?disabled=${entityConfig.overrides?.name === undefined}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="override-config">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -344,6 +339,24 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="override-config">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="override-checkbox"
|
||||
@change=${(e) => this._updateEntityOverride(index, 'name', e.target.checked)}
|
||||
.checked=${entityConfig.overrides?.name !== undefined}
|
||||
/>
|
||||
<span class="override-label">名称:</span>
|
||||
<input
|
||||
type="text"
|
||||
class="override-input"
|
||||
@change=${(e) => this._updateEntityOverrideValue(index, 'name', e.target.value)}
|
||||
.value=${entityConfig.overrides?.name || ''}
|
||||
placeholder="自定义名称"
|
||||
?disabled=${entityConfig.overrides?.name === undefined}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="override-config">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -371,13 +384,11 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
||||
/>
|
||||
<span class="override-label">预警:</span>
|
||||
<input
|
||||
type="number"
|
||||
type="text"
|
||||
class="override-input"
|
||||
@change=${(e) => this._updateEntityOverrideValue(index, 'warning', e.target.value)}
|
||||
.value=${entityConfig.overrides?.warning || ''}
|
||||
placeholder="预警值"
|
||||
min="0"
|
||||
step="0.01"
|
||||
placeholder="如: >10, <=5, ==on, ==off, =='hello world'"
|
||||
?disabled=${entityConfig.overrides?.warning === undefined}
|
||||
/>
|
||||
</div>
|
||||
@@ -393,7 +404,7 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
||||
• 名称重定义:勾选后可自定义显示名称<br>
|
||||
• 图标重定义:勾选后可自定义图标(如 mdi:phone)<br>
|
||||
• 单位重定义:勾选后可自定义单位(如 元、$、kWh 等)<br>
|
||||
• 预警值:勾选后设置预警值,低于此值显示红色<br>
|
||||
• 预警条件:勾选后设置预警条件,支持 >10, >=10, <10, <=10, ==10, ==on, ==off, =="hello world" 等<br>
|
||||
• 未勾选重定义时,将使用实体的原始属性值
|
||||
</div>
|
||||
</div>
|
||||
@@ -455,11 +466,12 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
||||
newEntities = currentEntities.filter(e => e.entity_id !== entityId);
|
||||
} else {
|
||||
// 添加实体
|
||||
newEntities = [...currentEntities, {
|
||||
const newEntity = {
|
||||
entity_id: entityId,
|
||||
attribute: null,
|
||||
overrides: undefined
|
||||
}];
|
||||
};
|
||||
// 只有在明确指定属性时才添加 attribute 字段
|
||||
newEntities = [...currentEntities, newEntity];
|
||||
}
|
||||
|
||||
this.config = {
|
||||
@@ -499,10 +511,17 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
||||
const newEntities = [...currentEntities];
|
||||
|
||||
if (newEntities[index]) {
|
||||
newEntities[index] = {
|
||||
...newEntities[index],
|
||||
attribute: attributeValue.trim() || null
|
||||
};
|
||||
const updatedEntity = { ...newEntities[index] };
|
||||
|
||||
if (attributeValue.trim()) {
|
||||
// 只有当属性值不为空时才设置 attribute 字段
|
||||
updatedEntity.attribute = attributeValue.trim();
|
||||
} else {
|
||||
// 如果属性值为空,则移除 attribute 字段
|
||||
delete updatedEntity.attribute;
|
||||
}
|
||||
|
||||
newEntities[index] = updatedEntity;
|
||||
}
|
||||
|
||||
this.config = {
|
||||
@@ -783,7 +802,7 @@ class XiaoshiBalanceCard extends LitElement {
|
||||
}
|
||||
|
||||
.device-icon {
|
||||
margin-left: 12px;
|
||||
margin-right: 12px;
|
||||
color: var(--fg-color, #000);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@@ -910,6 +929,9 @@ class XiaoshiBalanceCard extends LitElement {
|
||||
// 尝试从属性中获取单位
|
||||
if (attributes.unit_of_measurement) {
|
||||
unit = attributes.unit_of_measurement;
|
||||
} else {
|
||||
// 如果实体没有单位,则不显示单位
|
||||
unit = '';
|
||||
}
|
||||
|
||||
// 应用属性重定义
|
||||
@@ -929,7 +951,7 @@ class XiaoshiBalanceCard extends LitElement {
|
||||
unit = entityConfig.overrides.unit_of_measurement;
|
||||
}
|
||||
if (entityConfig.overrides.warning !== undefined && entityConfig.overrides.warning !== '') {
|
||||
warningThreshold = parseFloat(entityConfig.overrides.warning);
|
||||
warningThreshold = entityConfig.overrides.warning; // 保持原始字符串
|
||||
}
|
||||
}
|
||||
|
||||
@@ -967,6 +989,54 @@ class XiaoshiBalanceCard extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
_evaluateWarningCondition(value, condition) {
|
||||
if (!condition) return false;
|
||||
|
||||
// 解析条件字符串,支持操作符后可能有空格
|
||||
const match = condition.match(/^(>=|<=|>|<|==|!=)\s*(.+)$/);
|
||||
if (!match) return false;
|
||||
|
||||
const operator = match[1];
|
||||
let compareValue = match[2].trim();
|
||||
|
||||
// 移除比较值两端的引号(如果有的话)
|
||||
if ((compareValue.startsWith('"') && compareValue.endsWith('"')) ||
|
||||
(compareValue.startsWith("'") && compareValue.endsWith("'"))) {
|
||||
compareValue = compareValue.slice(1, -1);
|
||||
}
|
||||
|
||||
// 尝试将值转换为数字
|
||||
const numericValue = parseFloat(value);
|
||||
const numericCompare = parseFloat(compareValue);
|
||||
|
||||
// 如果两个值都是数字,进行数值比较
|
||||
if (!isNaN(numericValue) && !isNaN(numericCompare)) {
|
||||
switch (operator) {
|
||||
case '>': return numericValue > numericCompare;
|
||||
case '>=': return numericValue >= numericCompare;
|
||||
case '<': return numericValue < numericCompare;
|
||||
case '<=': return numericValue <= numericCompare;
|
||||
case '==': return numericValue === numericCompare;
|
||||
case '!=': return numericValue !== numericCompare;
|
||||
}
|
||||
}
|
||||
|
||||
// 字符串比较(用于 ==on, ==off, ==66 66 等)
|
||||
const stringValue = String(value);
|
||||
const stringCompare = compareValue;
|
||||
|
||||
switch (operator) {
|
||||
case '==': return stringValue === stringCompare;
|
||||
case '!=': return stringValue !== stringCompare;
|
||||
case '>': return stringValue > stringCompare;
|
||||
case '>=': return stringValue >= stringCompare;
|
||||
case '<': return stringValue < stringCompare;
|
||||
case '<=': return stringValue <= stringCompare;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
if (!this.hass) {
|
||||
@@ -994,16 +1064,24 @@ class XiaoshiBalanceCard extends LitElement {
|
||||
html`<div class="no-devices">请配置余额实体</div>` :
|
||||
html`
|
||||
${this._oilPriceData.map(balanceData => {
|
||||
const numericValue = parseFloat(balanceData.value);
|
||||
const isWarning = balanceData.warning_threshold !== undefined &&
|
||||
!isNaN(numericValue) &&
|
||||
numericValue < balanceData.warning_threshold;
|
||||
// 明细预警优先级最高
|
||||
let isWarning = false;
|
||||
|
||||
// 首先检查明细预警,如果存在且满足条件,直接设为预警状态
|
||||
if (balanceData.warning_threshold && balanceData.warning_threshold.trim() !== '') {
|
||||
isWarning = this._evaluateWarningCondition(balanceData.value, balanceData.warning_threshold);
|
||||
} else {
|
||||
// 只有在没有明细预警时才检查全局预警
|
||||
if (this.config.global_warning && this.config.global_warning.trim() !== '') {
|
||||
isWarning = this._evaluateWarningCondition(balanceData.value, this.config.global_warning);
|
||||
}
|
||||
}
|
||||
|
||||
return html`
|
||||
<div class="device-item" @click=${() => this._handleEntityClick(balanceData)}>
|
||||
<div class="device-left">
|
||||
<div class="device-name">${balanceData.friendly_name}</div>
|
||||
<ha-icon class="device-icon" icon="${balanceData.icon}"></ha-icon>
|
||||
<div class="device-name">${balanceData.friendly_name}</div>
|
||||
</div>
|
||||
<div class="device-value ${isWarning ? 'warning' : ''}">
|
||||
${balanceData.value}
|
||||
|
||||
1569
xiaoshi-device-consumables-button.js
Normal file
1569
xiaoshi-device-consumables-button.js
Normal file
File diff suppressed because it is too large
Load Diff
2397
xiaoshi-device-consumables-button2.js
Normal file
2397
xiaoshi-device-consumables-button2.js
Normal file
File diff suppressed because it is too large
Load Diff
1339
xiaoshi-device-consumables-card.js
Normal file
1339
xiaoshi-device-consumables-card.js
Normal file
File diff suppressed because it is too large
Load Diff
1392
xiaoshi-device-ha-info-card.js
Normal file
1392
xiaoshi-device-ha-info-card.js
Normal file
File diff suppressed because it is too large
Load Diff
1305
xiaoshi-device-todo-card.js
Normal file
1305
xiaoshi-device-todo-card.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -68,6 +68,19 @@ class XiaoshiUpdateCardEditor extends LitElement {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
@change=${this._entityChanged}
|
||||
.checked=${this.config.skip_updates !== false}
|
||||
name="skip_updates"
|
||||
/>
|
||||
包含已跳过的更新
|
||||
</label>
|
||||
<div class="help-text">如果勾选,将包含标记为跳过的版本更新</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -75,10 +88,17 @@ class XiaoshiUpdateCardEditor extends LitElement {
|
||||
}
|
||||
|
||||
_entityChanged(e) {
|
||||
const { name, value } = e.target;
|
||||
if (!value && name !== 'theme' && name !== 'width') return;
|
||||
const { name, value, type, checked } = e.target;
|
||||
|
||||
let finalValue = value;
|
||||
let finalValue;
|
||||
|
||||
// 处理复选框
|
||||
if (type === 'checkbox') {
|
||||
finalValue = checked;
|
||||
} else {
|
||||
if (!value && name !== 'theme' && name !== 'width') return;
|
||||
finalValue = value;
|
||||
}
|
||||
|
||||
// 处理不同字段的默认值
|
||||
if (name === 'width') {
|
||||
@@ -139,7 +159,6 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
align-items: center;
|
||||
padding: 16px;
|
||||
background: var(--bg-color, #fff);
|
||||
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
@@ -169,7 +188,6 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
}
|
||||
|
||||
/*标题统计数字*/
|
||||
@@ -251,7 +269,8 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
align-items: center;
|
||||
padding: 0px;
|
||||
border-bottom: 1px solid rgb(150,150,150,0.2);
|
||||
margin: 0 24px 8px 32px;
|
||||
margin: 0 32px 4px 32px;
|
||||
padding: 4px 0 0 0;
|
||||
}
|
||||
|
||||
/*设备、实体明细背景*/
|
||||
@@ -259,7 +278,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
min-height: 0;
|
||||
padding: 0 0 8px 0;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.device-icon {
|
||||
@@ -274,7 +293,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
.device-name {
|
||||
font-weight: 500;
|
||||
color: var(--fg-color, #000);
|
||||
margin-bottom: 4px;
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
.device-entity {
|
||||
@@ -286,7 +305,6 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
.device-details {
|
||||
font-size: 10px;
|
||||
color: var(--fg-color, #000);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.device-last-seen {
|
||||
@@ -307,13 +325,13 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
|
||||
.no-devices {
|
||||
text-align: center;
|
||||
padding: 8px 0 0 0;
|
||||
padding: 8px 0;
|
||||
color: var(--fg-color, #000);
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 0px;
|
||||
padding: 10px 0px;
|
||||
color: var(--fg-color, #000);
|
||||
}
|
||||
|
||||
@@ -389,12 +407,12 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
/* 备份信息独立容器 */
|
||||
.backup-info {
|
||||
padding: 4px 0 4px 16px;
|
||||
margin: 0 16px 0 30px;
|
||||
border-bottom: 1px solid rgb(150,150,150,0.2);
|
||||
margin: 0 32px 8px 32px;
|
||||
display: grid;
|
||||
grid-template-columns: auto auto auto;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid rgb(150,150,150,0.2);
|
||||
}
|
||||
`;
|
||||
}
|
||||
@@ -449,6 +467,17 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
_handleEntityClick(entity) {
|
||||
navigator.vibrate(50);
|
||||
// 点击实体时打开实体详情页
|
||||
if (entity.entity_id) {
|
||||
// 使用您建议的第一种方式
|
||||
const evt = new Event('hass-more-info', { composed: true });
|
||||
evt.detail = { entityId: entity.entity_id };
|
||||
this.dispatchEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
async _loadUpdateData() {
|
||||
if (!this.hass) return;
|
||||
|
||||
@@ -459,19 +488,10 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
const haUpdates = [];
|
||||
const otherUpdates = [];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取update.开头的实体更新信息
|
||||
try {
|
||||
const entities = Object.values(this.hass.states);
|
||||
const skipUpdates = this.config.skip_updates !== false; // 默认为true
|
||||
|
||||
entities.forEach(entity => {
|
||||
// 筛选以update.开头的实体
|
||||
@@ -484,6 +504,15 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
attributes.installed_version &&
|
||||
attributes.latest_version !== attributes.installed_version) {
|
||||
|
||||
// 如果不跳过更新,检查skipped_version属性
|
||||
if (!skipUpdates) {
|
||||
const skippedVersion = attributes.skipped_version;
|
||||
// 如果skipped_version不为null且等于latest_version,则跳过此更新
|
||||
if (skippedVersion !== null && skippedVersion === attributes.latest_version) {
|
||||
return; // 跳过此更新
|
||||
}
|
||||
}
|
||||
|
||||
const updateData = {
|
||||
name: attributes.friendly_name || entity.entity_id.replace('update.', ''),
|
||||
current_version: attributes.installed_version,
|
||||
@@ -493,7 +522,8 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
entity_id: entity.entity_id,
|
||||
title: attributes.title || '',
|
||||
release_url: attributes.release_url || '',
|
||||
entity_picture: attributes.entity_picture || ''
|
||||
entity_picture: attributes.entity_picture || '',
|
||||
skipped_version: attributes.skipped_version || null
|
||||
};
|
||||
|
||||
// 检查是否为home_assistant开头的实体
|
||||
@@ -521,15 +551,11 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
this._loading = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
_handleRefresh() {
|
||||
this._loadUpdateData();
|
||||
navigator.vibrate(50);
|
||||
}
|
||||
|
||||
|
||||
|
||||
_handleUpdateClick(update) {
|
||||
navigator.vibrate(50);
|
||||
// 点击更新项时弹出实体详情
|
||||
@@ -560,6 +586,10 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
|
||||
if (confirmed) {
|
||||
this._executeUpdate(update);
|
||||
// 延迟3秒后刷新数据,给更新操作足够时间完成
|
||||
setTimeout(() => {
|
||||
this._loadUpdateData();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -765,9 +795,6 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
return html`${backupElements}`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
if (!this.hass) {
|
||||
return html`<div class="loading">等待Home Assistant连接...</div>`;
|
||||
@@ -804,19 +831,9 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
${this._renderHAVersionInfo()}
|
||||
</div>
|
||||
|
||||
<!-- 备份信息 -->
|
||||
<div class="section-divider">
|
||||
<div class="section-title">
|
||||
<span> • 备份信息</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="backup-info">
|
||||
${this._renderBackupInfo()}
|
||||
</div>
|
||||
|
||||
<div class="devices-list">
|
||||
${this._loading ?
|
||||
html`<div class="loading">加载中...</div>` :
|
||||
html`<div class="loading">HA版本信息加载中...</div>` :
|
||||
|
||||
(this._haUpdates.length === 0 && this._otherUpdates.length === 0) ?
|
||||
html`<div class="no-devices">✅ 所有组件都是最新版本</div>` :
|
||||
@@ -829,7 +846,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
</div>
|
||||
</div>
|
||||
${this._haUpdates.map(update => html`
|
||||
<div class="device-item">
|
||||
<div class="device-item" @click=${() => this._handleEntityClick(update)}>
|
||||
<div class="device-icon">
|
||||
<ha-icon icon="${update.icon}"></ha-icon>
|
||||
</div>
|
||||
@@ -837,6 +854,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
<div class="device-name">${update.name}</div>
|
||||
<div class="device-details">
|
||||
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
||||
${update.skipped_version ? html`<span style="color: #ff9800;"> 已跳过版本: ${update.skipped_version}</span>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
<div class="device-last-seen" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
||||
@@ -848,12 +866,12 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
${this._otherUpdates.length > 0 ? html`
|
||||
<div class="section-divider">
|
||||
<div class="section-title">
|
||||
<span> • 加载项、卡片更新</span>
|
||||
<span> • HACS更新</span>
|
||||
<span class="section-count ${this._otherUpdates.length > 0 ? 'non-zero' : 'zero'}">${this._otherUpdates.length}</span>
|
||||
</div>
|
||||
</div>
|
||||
${this._otherUpdates.map(update => html`
|
||||
<div class="device-item">
|
||||
<div class="device-item" @click=${() => this._handleEntityClick(update)}>
|
||||
<div class="device-icon">
|
||||
<ha-icon icon="${update.icon}"></ha-icon>
|
||||
</div>
|
||||
@@ -861,6 +879,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
<div class="device-name">${update.name}</div>
|
||||
<div class="device-details">
|
||||
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
||||
${update.skipped_version ? html`<span style="color: #ff9800;"> 已跳过版本: ${update.skipped_version}</span>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
<div class="device-last-seen" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
||||
@@ -870,6 +889,16 @@ export class XiaoshiUpdateCard extends LitElement {
|
||||
`)}\n ` : ''}
|
||||
`
|
||||
}
|
||||
|
||||
</div>
|
||||
<!-- 备份信息 -->
|
||||
<div class="section-divider">
|
||||
<div class="section-title">
|
||||
<span> • 备份信息</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="backup-info">
|
||||
${this._renderBackupInfo()}
|
||||
</div>
|
||||
</ha-card>
|
||||
`;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
console.info("%c 消逝卡-平板端 \n%c v 0.0.6 ", "color: red; font-weight: bold; background: black", "color: white; font-weight: bold; background: black");
|
||||
console.info("%c 消逝卡-平板端 \n%c v 0.1.4 ", "color: red; font-weight: bold; background: black", "color: white; font-weight: bold; background: black");
|
||||
|
||||
const loadCards = async () => {
|
||||
await import('./xiaoshi-pad-grid-card.js');
|
||||
await import('./xiaoshi-device-balance-card.js');
|
||||
await import('./xiaoshi-device-todo-card.js');
|
||||
await import('./xiaoshi-device-consumables-card.js');
|
||||
await import('./xiaoshi-device-consumables-button.js');
|
||||
await import('./xiaoshi-device-ha-info-card.js');
|
||||
await import('./xiaoshi-device-update-card.js');
|
||||
await import('./xiaoshi-device-offline-card.js');
|
||||
await import('./xiaoshi-device-balance-card.js');
|
||||
|
||||
window.customCards = window.customCards || [];
|
||||
window.customCards.push(...cardConfigs);
|
||||
@@ -17,15 +21,9 @@ const cardConfigs = [
|
||||
description: '温度分布、湿度分布'
|
||||
},
|
||||
{
|
||||
type: 'xiaoshi-update-card',
|
||||
name: '消逝卡HA更新监控卡片',
|
||||
description: '显示需要更新的组件和版本',
|
||||
preview: true
|
||||
},
|
||||
{
|
||||
type: 'xiaoshi-offline-card',
|
||||
name: '消逝卡HA离线设备卡片',
|
||||
description: '显示所有离线的设备和实体',
|
||||
type: 'xiaoshi-ha-info-card',
|
||||
name: '消逝卡HA信息卡片',
|
||||
description: '消逝卡HA信息卡片',
|
||||
preview: true
|
||||
},
|
||||
{
|
||||
@@ -33,6 +31,18 @@ const cardConfigs = [
|
||||
name: '消逝电话余额卡',
|
||||
description: '消逝电话余额卡',
|
||||
preview: true
|
||||
},
|
||||
{
|
||||
type: 'xiaoshi-todo-card',
|
||||
name: '消逝待办事项',
|
||||
description: '消逝待办事项',
|
||||
preview: true
|
||||
},
|
||||
{
|
||||
type: 'xiaoshi-consumables-card',
|
||||
name: '消逝耗材统计',
|
||||
description: '消逝耗材统计',
|
||||
preview: true
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user