找回密码
 立即注册
查看: 290|回复: 3

[UI界面] 分享:自定义洗衣机状态卡片(带运行动画效果)

[复制链接]

1

主题

36

回帖

227

积分

中级会员

积分
227
金钱
190
HASS币
0
发表于 2025-4-4 23:53:34 | 显示全部楼层 |阅读模式

分享:自定义洗衣机状态卡片(带运行动画效果)

大家好!今天给大家分享一个我为洗衣机定制的 Mushroom 模板卡片,这个卡片不仅能显示洗衣机的运行状态、剩余时间,还有一个很酷的动态效果——当洗衣机运行时,徽章图标会自动旋转!

效果展示

  • 当洗衣机关机时:显示"已关机"
  • 当洗衣机开机但未运行程序时:显示"已开机"
  • 当洗衣机运行程序时:显示当前洗衣模式和剩余时间,同时徽章图标旋转

代码分享

type: custom:mushroom-template-card
layout: horizontal
primary: |-
  {% if states("binary_sensor.a08222021fda_laundrycyclestatus") == 'on' %}
    洗衣机 - {{states('select.a08222021fda_laundrycycle')}}
  {% else %}
    洗衣机
  {% endif %}
secondary: |-
  {% if states("binary_sensor.a08222021fda_laundrycyclestatus") == 'on' %}
    剩余时间 {{ states('sensor.a08222021fda_remainingtimehh') }}:{{ '%02d' | format(states('sensor.a08222021fda_remainingtimemm') | int) }}
  {% elif states("switch.a08222021fda_onoffstatus") == 'on' %}
    已开机
  {% else %}
    已关机
  {% endif %}
icon: mdi:washing-machine
entity: switch.a08222021fda_onoffstatus
badge_icon: |-
  {% if states("binary_sensor.a08222021fda_laundrycyclestatus") == 'on' %}
  mdi:pinwheel
  {% endif %}
badge_color: |-
  {% if states("binary_sensor.a08222021fda_laundrycyclestatus") == 'on' %}
    #ff9f09
  {% endif %}
icon_color: |
  {% if states('switch.a08222021fda_onoffstatus') == 'on' %}
    red
  {% endif %}
fill_container: true
card_mod:
  style: |
    ha-card {
      --card-primary-font-size: 32px;
      --card-secondary-font-size: 16px;
    }
    {% if states("binary_sensor.a08222021fda_laundrycyclestatus") == 'on' %}
    ha-card .badge ha-icon {
      animation: spin 2s linear infinite;
    }
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    {% endif %}

使用说明

  1. 需要安装以下HACS前端插件:

    • Mushroom Cards
    • card-mod
  2. 需要替换代码中的实体ID为你自己的洗衣机实体:

    • switch.a08222021fda_onoffstatus - 洗衣机开关状态
    • binary_sensor.a08222021fda_laundrycyclestatus - 洗衣机运行状态
    • select.a08222021fda_laundrycycle - 洗衣模式
    • sensor.a08222021fda_remainingtimehh - 剩余小时
    • sensor.a08222021fda_remainingtimemm - 剩余分钟
  3. 可以根据需要调整字体大小和动画速度

技术说明

  • 使用 card_mod 实现了徽章图标的旋转动画
  • 通过条件判断实现不同状态下的显示内容
  • 使用格式化函数确保分钟显示为两位数

希望这个卡片对大家有用!如果有任何问题或改进建议,欢迎在评论区留言。

1743781750105.png
1743781944027.png
1743781920852.png
回复

使用道具 举报

5

主题

247

回帖

1553

积分

金牌会员

积分
1553
金钱
1301
HASS币
0
发表于 2025-4-5 09:48:44 | 显示全部楼层
什么牌子的洗衣机
回复

使用道具 举报

1

主题

36

回帖

227

积分

中级会员

积分
227
金钱
190
HASS币
0
 楼主| 发表于 2025-4-5 23:15:27 | 显示全部楼层
gtyun 发表于 2025-4-5 09:48
什么牌子的洗衣机

海尔      
回复

使用道具 举报

0

主题

66

回帖

343

积分

中级会员

积分
343
金钱
277
HASS币
0
发表于 2025-4-6 19:32:59 | 显示全部楼层

海尔现在只要抓包就卡死不能登录
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2025-5-1 09:54 , Processed in 1.061189 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表