一个卡片搞定全家智能插座 — Smart Plug Card 上手体验
开关状态、实时功率、用电量,一张卡片全掌握。
---
🔍 你是不是也这样?
智能家居里的插座越来越多,但 HA 默认只能看到一个个独立的实体:
😑 想看空调插座功率,要点进实体详情
😑 想看今天用了多少电,要再点进另一个实体
😑 想对比几个插座的用电,要开好几个窗口
😑 开关状态、功率、电压、电流、用电量,散落在五六个实体里
信息碎片化,一眼看不全。
---
💡 一张卡片,聚合所有关键数据
Smart Plug Card是一个 Home Assistant 自定义卡片,把智能插座的所有关键数据聚合到一张卡片里:
```yaml
type:custom:smart-plug-card
title:客厅插座
switch_entity:switch.living_room_plug
power_entity:sensor.living_room_plug_power
voltage_entity:sensor.living_room_plug_voltage
current_entity:sensor.living_room_plug_current
daily_energy_entity:sensor.living_room_plug_daily
monthly_energy_entity:sensor.living_room_plug_monthly
```
效果:

✨ 六大核心功能
1️⃣ 开关状态,一目了然
开启/关闭状态用绿色/红色标签直观展示,不需要点进实体看`on`/`off`。
2️⃣ 功率 · 电压 · 电流,三列并排
再也不用来回切实体。功率、电压、电流三列网格排布,一眼扫完:
3️⃣ 日用电量 · 月用电量
直接在卡片底部显示今日和本月累计用电,省去翻统计页面的麻烦。
4️⃣ 💡 指示灯状态
支持两种指示灯配置:
indicator_entity(binary_sensor)— 显示指示灯亮/灭indicator_light_entity(sensor)— 显示指示灯亮度或其他数值
5️⃣ 横向多列布局
多个插座不想上下堆叠?切换横向模式,并排显示:
```yaml
type:custom:smart-plug-card
display_mode:horizontal # 横向布局
columns:2 # 2列显示
entities:
-name:客厅空调
switch_entity:switch.living_room_ac
power_entity:sensor.living_room_ac_power
-name:卧室风扇
switch_entity:switch.bedroom_fan
power_entity:sensor.bedroom_fan_power
```
效果:

6️⃣ 深色主题自动适配
使用 HA 官方 CSS 变量,主题切换时颜色自动跟随,无需手动配置。

---
📋 完整配置一览

| 参数 | 说明 | 默认值 |
|------|------|--------|
|`switch_entity`| 开关实体(必需) | — |
|`power_entity`| 功率传感器(W) | 可选 |
|`voltage_entity`| 电压传感器(V) | 可选 |
|`current_entity`| 电流传感器(A) | 可选 |
|`daily_energy_entity`| 日用电量(kWh) | 可选 |
|`monthly_energy_entity`| 月用电量(kWh) | 可选 |
|`indicator_entity`| 指示灯状态(亮/灭) | 可选 |
|`indicator_light_entity`| 指示灯亮度 | 可选 |
|`display_mode`| vertical / horizontal | vertical |
|`columns`| 横向模式列数 | 2 |
>所有传感器都是**可选**的,没配置的字段自动显示`--`,不影响其他字段。
---
🚀 安装方式

HACS 安装(推荐)
HACS → 前端 → 右下角 + → 自定义仓库
类别选 Lovelace → 安装
手动安装
下载
smart-plug-card.js到/config/www/配置资源引用:
```yaml
lovelace:
resources:
-url:/local/smart-plug-card.js
type:module
```
3.重启 HA → 添加卡片
---
🛠 常见问题
Q: 功率/电压/电流显示 "--"?
>确认对应的传感器实体 ID 正确,且状态不为`unavailable`。
Q: 多个插座怎么配?
>用`entities`列表,每个插座一个对象,支持混合配置详细字段。
Q: 想用深色主题?
>卡片默认跟随 HA 主题,无需额外配置。如需自定义:
>```yaml
>background_color:'#1a1f2e'
>text_color:'#f1f5f9'
>secondary_color:'#94a3b8'
>```
---
🔗 项目地址
版本:v1.3.0
许可证:MIT 开源免费
---
同系列卡片
三个卡片搭配使用,电量、用电、话费,关键信息一屏搞定。
---
专注 Home Assistant 自动化技巧与插件开发

无字添书
校验提示文案
无字添书
校验提示文案