From d8d4389549d8be363a0bdbb7e03438cf49fe6486 Mon Sep 17 00:00:00 2001
From: xiaoshi <115949669+xiaoshi930@users.noreply.github.com>
Date: Wed, 26 Nov 2025 12:07:35 +0800
Subject: [PATCH] Update xiaoshi-device-update-card.js
---
xiaoshi-device-update-card.js | 54 ++++++++++++++++++++++++-----------
1 file changed, 37 insertions(+), 17 deletions(-)
diff --git a/xiaoshi-device-update-card.js b/xiaoshi-device-update-card.js
index ef3b79b..e0a36e7 100644
--- a/xiaoshi-device-update-card.js
+++ b/xiaoshi-device-update-card.js
@@ -68,6 +68,19 @@ class XiaoshiUpdateCardEditor extends LitElement {
+
+
@@ -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') {
@@ -459,19 +479,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 +495,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 +513,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开头的实体
@@ -765,9 +786,6 @@ export class XiaoshiUpdateCard extends LitElement {
return html`${backupElements}`;
}
-
-
-
render() {
if (!this.hass) {
return html`等待Home Assistant连接...
`;
@@ -837,6 +855,7 @@ export class XiaoshiUpdateCard extends LitElement {
${update.name}
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
+ ${update.skipped_version ? html`
已跳过版本: ${update.skipped_version}` : ''}
this._handleConfirmUpdate(update, e)}>
@@ -861,6 +880,7 @@ export class XiaoshiUpdateCard extends LitElement {
${update.name}
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
+ ${update.skipped_version ? html`
已跳过版本: ${update.skipped_version}` : ''}
this._handleConfirmUpdate(update, e)}>