Compare commits

..

85 Commits

Author SHA1 Message Date
xiaoshi
b221bacb78 Update xiaoshi-pad-card.js 2025-12-06 20:16:56 +08:00
xiaoshi
7b7f0c632d Update xiaoshi-device-todo-button.js 2025-12-06 20:16:06 +08:00
xiaoshi
1523dc76d3 Update xiaoshi-device-ha-info-button.js 2025-12-06 20:15:52 +08:00
xiaoshi
20eae200c1 Update xiaoshi-device-consumables-button.js 2025-12-06 20:15:39 +08:00
xiaoshi
763b1cc977 Update xiaoshi-pad-card.js 2025-12-06 19:44:27 +08:00
xiaoshi
3c54c6315e Add files via upload 2025-12-06 19:44:01 +08:00
xiaoshi
74c53128c8 Update xiaoshi-pad-card.js 2025-12-06 19:43:41 +08:00
xiaoshi
9973d7b614 Delete xiaoshi-device-update-card.js 2025-12-06 19:43:19 +08:00
xiaoshi
a4d4fba8a1 Delete xiaoshi-device-todo-card.js 2025-12-06 19:43:11 +08:00
xiaoshi
27d567803b Delete xiaoshi-device-offline-card.js 2025-12-06 19:43:01 +08:00
xiaoshi
b2bd56026c Delete xiaoshi-device-ha-info-card.js 2025-12-06 19:42:54 +08:00
xiaoshi
00b7fe4842 Delete xiaoshi-device-consumables-card.js 2025-12-06 19:42:47 +08:00
xiaoshi
8f96c49931 Delete xiaoshi-device-consumables-button.js 2025-12-06 19:42:38 +08:00
xiaoshi
2087327b69 Delete xiaoshi-device-balance-card.js 2025-12-06 19:42:21 +08:00
xiaoshi
7f415eba9a Update xiaoshi-pad-card.js 2025-12-01 10:11:58 +08:00
xiaoshi
4b7da24066 Update xiaoshi-device-consumables-button.js 2025-11-29 23:55:48 +08:00
xiaoshi
721b6a4ba2 Delete xiaoshi-device-consumables-button2.js 2025-11-29 23:55:37 +08:00
xiaoshi
b615d3dd7a Update xiaoshi-device-todo-card.js 2025-11-29 20:08:41 +08:00
xiaoshi
6f58598f54 Update xiaoshi-device-update-card.js 2025-11-29 00:07:04 +08:00
xiaoshi
f71e51029c Update xiaoshi-device-ha-info-card.js 2025-11-29 00:05:21 +08:00
xiaoshi
48f0c23456 Update xiaoshi-device-update-card.js 2025-11-28 23:20:14 +08:00
xiaoshi
910365f8b8 Update xiaoshi-device-ha-info-card.js 2025-11-28 23:20:04 +08:00
xiaoshi
81b40138f5 Update xiaoshi-pad-card.js 2025-11-28 21:50:16 +08:00
xiaoshi
4783085a99 Update xiaoshi-device-update-card.js 2025-11-28 21:49:39 +08:00
xiaoshi
737b174953 Update xiaoshi-device-todo-card.js 2025-11-28 21:49:28 +08:00
xiaoshi
d49426da73 Update xiaoshi-device-offline-card.js 2025-11-28 21:49:16 +08:00
xiaoshi
3bf33ef0cb Update xiaoshi-device-ha-info-card.js 2025-11-28 21:49:02 +08:00
xiaoshi
2c3c3fd42d Update xiaoshi-device-consumables-card.js 2025-11-28 21:48:49 +08:00
xiaoshi
4fe21a2c74 Update xiaoshi-device-consumables-button2.js 2025-11-28 21:48:35 +08:00
xiaoshi
3900897f15 Update xiaoshi-device-consumables-button.js 2025-11-28 21:48:19 +08:00
xiaoshi
2170f5423c Update xiaoshi-device-balance-card.js 2025-11-28 21:48:06 +08:00
xiaoshi
82e71cf38d Update xiaoshi-device-consumables-button.js 2025-11-28 20:49:17 +08:00
xiaoshi
c79052b1e1 Update xiaoshi-device-consumables-button2.js 2025-11-28 20:49:01 +08:00
xiaoshi
5ef261877c Update xiaoshi-device-consumables-card.js 2025-11-28 20:48:46 +08:00
xiaoshi
da16f27cf2 Update xiaoshi-pad-card.js 2025-11-28 12:15:39 +08:00
xiaoshi
df6a678043 Update xiaoshi-device-ha-info-card.js 2025-11-28 12:15:25 +08:00
xiaoshi
82930f4e41 Update xiaoshi-device-update-card.js 2025-11-28 12:15:06 +08:00
xiaoshi
4a2ffb628d Create xiaoshi-device-consumables-button2.js 2025-11-28 00:31:54 +08:00
xiaoshi
3d5f6028c2 Update xiaoshi-device-todo-card.js 2025-11-27 21:10:40 +08:00
xiaoshi
765b0a1367 Update README.md 2025-11-27 15:50:13 +08:00
xiaoshi
df66608d7f Update xiaoshi-pad-card.js 2025-11-27 15:47:56 +08:00
xiaoshi
6ed3bca2cc Create xiaoshi-device-consumables-button.js 2025-11-27 15:47:20 +08:00
xiaoshi
f1d0b52bd7 Update xiaoshi-pad-card.js 2025-11-27 15:46:51 +08:00
xiaoshi
528eaf1cd1 Create xiaoshi-device-ha-info-card.js 2025-11-27 15:46:02 +08:00
xiaoshi
59268a91f8 Update xiaoshi-device-consumables-card.js 2025-11-27 15:45:29 +08:00
xiaoshi
f768186379 Update xiaoshi-device-balance-card.js 2025-11-26 14:21:37 +08:00
xiaoshi
2371475eca Update xiaoshi-device-consumables-card.js 2025-11-26 14:18:03 +08:00
xiaoshi
befca5ece5 Update xiaoshi-pad-card.js 2025-11-26 14:13:44 +08:00
xiaoshi
24848db29b Update xiaoshi-device-consumables-card.js 2025-11-26 14:13:25 +08:00
xiaoshi
be232dc056 Update README.md 2025-11-26 13:06:57 +08:00
xiaoshi
96fb548262 Update README.md 2025-11-26 13:06:09 +08:00
xiaoshi
16831e5102 Update xiaoshi-pad-card.js 2025-11-26 13:04:30 +08:00
xiaoshi
b05f7de548 Update xiaoshi-device-consumables-card.js 2025-11-26 13:04:02 +08:00
xiaoshi
d8d4389549 Update xiaoshi-device-update-card.js 2025-11-26 12:07:35 +08:00
xiaoshi
bca500c945 Update xiaoshi-device-balance-card.js 2025-11-26 11:56:44 +08:00
xiaoshi
5f36835adb Update xiaoshi-pad-card.js 2025-11-26 01:00:55 +08:00
xiaoshi
05d083c259 Update README.md 2025-11-26 00:59:56 +08:00
xiaoshi
3738b0b092 Update xiaoshi-device-consumables-card.js 2025-11-25 19:51:37 +08:00
xiaoshi
87e9e68b79 Update xiaoshi-pad-card.js 2025-11-25 19:22:55 +08:00
xiaoshi
7ddd378b9a Create xiaoshi-device-consumables-card.js 2025-11-25 19:22:06 +08:00
xiaoshi
23b6e5b8a3 Update xiaoshi-device-balance-card.js 2025-11-25 19:15:23 +08:00
xiaoshi
4067518d0d Update xiaoshi-device-todo-card.js 2025-11-25 18:30:32 +08:00
xiaoshi
53e06aacf7 Update xiaoshi-device-todo-card.js 2025-11-25 13:35:29 +08:00
xiaoshi
9a59c2bb90 Create xiaoshi-device-todo-card.js 2025-11-25 13:34:43 +08:00
xiaoshi
0ae5851361 Update xiaoshi-pad-card.js 2025-11-25 13:34:07 +08:00
xiaoshi
a17033c0f0 Update README.md 2025-11-25 13:33:09 +08:00
xiaoshi
44a1d81265 Update xiaoshi-pad-card.js 2025-11-24 15:34:14 +08:00
xiaoshi
2de0668d37 Update xiaoshi-device-balance-card.js 2025-11-24 15:33:59 +08:00
xiaoshi
a03a54663b Update README.md 2025-11-24 14:59:22 +08:00
xiaoshi
6efa2864cc Update xiaoshi-pad-card.js 2025-11-24 14:56:54 +08:00
xiaoshi
f4a37ff29c Update xiaoshi-device-balance-card.js 2025-11-24 14:55:54 +08:00
xiaoshi
1c5717f5d5 Create xiaoshi-device-balance-card.js 2025-11-24 13:27:17 +08:00
xiaoshi
15fcbf0250 Update xiaoshi-pad-card.js 2025-11-24 13:25:31 +08:00
xiaoshi
de31cf6464 Update xiaoshi-pad-card.js 2025-11-24 11:38:36 +08:00
xiaoshi
9f6a31f1df Update xiaoshi-device-offline-card.js 2025-11-24 11:38:21 +08:00
xiaoshi
f1535f81e4 Update xiaoshi-pad-card.js 2025-11-23 23:33:21 +08:00
xiaoshi
c30552dfca Update xiaoshi-device-offline-card.js 2025-11-23 23:32:57 +08:00
xiaoshi
deb3c38e87 Update xiaoshi-device-update-card.js 2025-11-23 23:32:22 +08:00
xiaoshi
c3c7d4a165 Update xiaoshi-pad-card.js 2025-11-23 23:21:54 +08:00
xiaoshi
35a1a2e6a8 Update xiaoshi-device-update-card.js 2025-11-23 23:21:25 +08:00
xiaoshi
fe55af23e4 Update README.md 2025-11-23 22:52:02 +08:00
xiaoshi
e1c926be4b Update xiaoshi-pad-card.js 2025-11-23 22:49:10 +08:00
xiaoshi
3a39798dfc Add files via upload 2025-11-23 22:48:17 +08:00
xiaoshi
68129eeca8 Delete xiaoshi-pad-slider-card.js 2025-11-23 22:47:55 +08:00
xiaoshi
64e56a81ba Update README.md 2025-11-12 16:52:37 +08:00
11 changed files with 13383 additions and 182 deletions

View File

@@ -1,7 +1,7 @@
# 消逝卡(平板端)
## 配置资源文件
~~~
- url: /hacsfiles/xiaoshi-pad-card/xiaoshi-card.js
- url: /hacsfiles/xiaoshi-pad-card/xiaoshi-pad-card.js
type: module
~~~
@@ -24,18 +24,76 @@ max: 80 # 当前地区最大值
mode: 湿度 # 【温度】或者【湿度】
~~~
## 功能2进度条
## 功能2HA信息卡(手机平板端通用)
**引用示例**
~~~
type: custom:xiaoshi-pad-slider-card
entity: number.xxxxxxx
style:
slider-width: 110px # 总宽度默认100px
slider-height: 10px # 总高度默认30px
track-color: rgba(200,200,200,0.5) # 背景色默认rgba(255,255,255,0.3)
thumb-size: 15px # 进度点大小默认15px
thumb-color: rgb(255,255,255) # 进度点颜色,默认,白色
slider-color: rgb(25,155,125) # 进度条背景色,默认,浅蓝色
track-height: 20px # 进度条高度默认5px
track-radius: 4px # 圆角大小默认2px
type: custom:xiaoshi-update-card
width: 100%
skip_updates: false #是否包含已跳过的更新
theme: on
exclude_devices:
- *设备*
exclude_entities:
- *shiti*
~~~
## 功能3电话信息余额卡(手机平板端通用)
**引用示例**
~~~
type: custom:xiaoshi-balance-card
name: 电话余额信息
width: 100%
theme: on
entities:
- entity_id: sensor.999
attribute: null
overrides:
icon: ""
name: ""
unit_of_measurement: ""
warning: ""
- entity_id: input_boolean.777
attribute: friendly_name
overrides:
name: ""
icon: ""
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
~~~

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1328
xiaoshi-device-todo-card.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,15 @@
console.info("%c 消逝卡-平板端 \n%c v 0.0.0 ", "color: red; font-weight: bold; background: black", "color: white; font-weight: bold; background: black");
console.info("%c 消逝卡-平板端 \n%c v 0.1.8 ", "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-pad-slider-card.js');
await import('./xiaoshi-device-balance-card.js');
await import('./xiaoshi-device-balance-button.js');
await import('./xiaoshi-device-todo-card.js');
await import('./xiaoshi-device-todo-button.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-ha-info-button.js');
window.customCards = window.customCards || [];
window.customCards.push(...cardConfigs);
@@ -15,10 +22,53 @@ const cardConfigs = [
description: '温度分布、湿度分布'
},
{
type: 'xiaoshi-pad-slider-card',
name: '消逝卡(平板端)-进度条',
description: '进度条'
type: 'xiaoshi-ha-info-card',
name: '消逝HA信息卡片',
description: '消逝HA信息卡片',
preview: true
},
{
type: 'xiaoshi-ha-info-button',
name: '消逝HA信息按钮',
description: '消逝HA信息按钮',
preview: true
},
{
type: 'xiaoshi-balance-card',
name: '消逝余额信息卡片',
description: '消逝余额信息卡片',
preview: true
},
{
type: 'xiaoshi-balance-button',
name: '消逝余额信息按钮',
description: '消逝余额信息按钮',
preview: true
},
{
type: 'xiaoshi-todo-card',
name: '消逝待办信息卡片',
description: '消逝待办信息卡片',
preview: true
},
{
type: 'xiaoshi-todo-button',
name: '消逝待办信息按钮',
description: '消逝待办信息按钮',
preview: true
},
{
type: 'xiaoshi-consumables-card',
name: '消逝耗材信息卡片',
description: '消逝耗材信息卡片',
preview: true
},
{
type: 'xiaoshi-consumables-button',
name: '消逝耗材信息按钮',
description: '消逝耗材信息按钮',
preview: true
}
];
loadCards();
loadCards();

View File

@@ -1,163 +0,0 @@
import { LitElement, html, css } from "https://unpkg.com/lit-element@2.4.0/lit-element.js?module";
export class XiaoshiPadSliderCard extends LitElement {
static get properties() {
return {
hass: Object,
config: Object,
_value: Number,
_min: Number,
_max: Number,
_dragging: Boolean
};
}
static get styles() {
return css`
.slider-root {
position: relative;
width: var(--slider-width, 100%);
height: var(--slider-height, 30px);
touch-action: none;
}
.slider-track {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 100%;
height: var(--track-height, 5px);
background: var(--track-color, rgba(255,255,255,0.3));
border-radius: var(--track-radius, 2px);
}
.slider-fill {
position: absolute;
height: 100%;
background: var(--slider-color, #f00);
border-radius: inherit;
}
.slider-thumb {
position: absolute;
top: 50%;
width: var(--thumb-size, 15px);
height: var(--thumb-size, 15px);
background: var(--thumb-color, #fff);
border-radius: 50%;
transform: translate(-50%, -50%);
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
`;
}
constructor() {
super();
this._value = 0;
this._min = 0;
this._max = 100;
this._dragging = false;
this._startX = 0;
this._startValue = 0;
this._moveHandler = (e) => this._handleDrag(e);
this._endHandler = () => this._endDrag();
}
setConfig(config) {
if (!config.entity) throw new Error('必须指定实体');
this.config = config;
if (config.style) {
Object.keys(config.style).forEach(key => {
this.style.setProperty(`--${key}`, config.style[key]);
});
}
}
updated(changedProperties) {
if (changedProperties.has('hass')) {
const state = this.hass.states[this.config.entity];
if (state) {
this._value = Number(state.state);
this._min = Number(state.attributes.min || 0);
this._max = Number(state.attributes.max || 100);
}
}
}
render() {
const percent = Math.max(0, Math.min(100, (this._value - this._min) / (this._max - this._min) * 100));
return html`
<div class="slider-root"\n
@mousedown=${this._startDrag}\n
@touchstart=${this._startDrag}>
<div class="slider-track">
<div class="slider-fill"\nstyle="width: ${percent}%"></div>
<div class="slider-thumb"\nstyle="left: ${percent}%"></div>
</div>
</div>
`;
}
_startDrag(e) {
e.preventDefault();
this._dragging = true;
const slider = this.shadowRoot.querySelector('.slider-track');
const rect = slider.getBoundingClientRect();
this._sliderLeft = rect.left;
this._sliderWidth = rect.width;
window.addEventListener('mousemove', this._moveHandler);
window.addEventListener('touchmove', this._moveHandler, { passive: false });
window.addEventListener('mouseup', this._endHandler);
window.addEventListener('touchend', this._endHandler);
const clientX = e.type === 'touchstart' ? e.touches[0].clientX : e.clientX;
this._updateValue((clientX - this._sliderLeft) / this._sliderWidth);
}
_endDrag() {
if (!this._dragging) return;
this._dragging = false;
this._removeEventListeners();
}
_handleDrag(e) {
if (!this._dragging) return;
e.preventDefault();
const clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
this._updateValue((clientX - this._sliderLeft) / this._sliderWidth);
}
_removeEventListeners() {
window.removeEventListener('mousemove', this._moveHandler);
window.removeEventListener('touchmove', this._moveHandler);
window.removeEventListener('mouseup', this._endHandler);
window.removeEventListener('touchend', this._endHandler);
}
disconnectedCallback() {
super.disconnectedCallback();
this._removeEventListeners();
}
_updateValue(ratio) {
const safeRatio = Math.max(0, Math.min(1, ratio));
const newValue = this._min + safeRatio * (this._max - this._min);
const roundedValue = Math.round(newValue);
if (roundedValue !== this._value) {
this._value = roundedValue;
this._debouncedSetValue(roundedValue);
}
}
_debouncedSetValue(value) {
clearTimeout(this._debounceTimer);
this._debounceTimer = setTimeout(() => {
this._callService(value);
}, 50);
}
_callService(value) {
const service = this.config.entity.split('.')[0];
this.hass.callService(service, 'set_value', {
entity_id: this.config.entity,
value: value
});
}
}
customElements.define('xiaoshi-pad-slider-card', XiaoshiPadSliderCard);