找回密码
 立即注册
楼主: wangmucha

[求助] 怎么将所有开启的灯自动集合到一个卡片自动显示

[复制链接]

20

主题

483

回帖

3405

积分

论坛元老

积分
3405
金钱
2902
HASS币
8
发表于 2023-6-11 09:02:43 来自手机 | 显示全部楼层
本帖最后由 cjnt007 于 2023-6-11 09:44 编辑

以下代码放开发者工具-模板里测试下:
{% set ns = namespace() %}
{%- set lights = states.switch
            | selectattr('state', 'eq', 'on')
            | list %}
{%- set ns.lists = ''%}
{%- for item in lights %}
{{item.attributes["friendly_name"] }}
{%- endfor %}

测试没问题,放到markdown卡片里使用
第二行里,states.switch换成states.light可列出light设备

回复

使用道具 举报

8

主题

686

回帖

4693

积分

论坛元老

积分
4693
金钱
3994
HASS币
0
QQ
发表于 2023-6-11 09:44:28 | 显示全部楼层
wangmucha 发表于 2023-6-11 01:18
你这个不是我现在说的这个 不过我也看到过你这个 大分类管理也挺好! 可以分享出来大家学习研究吗 ...

最上面那一行,那个灯泡不就是你说的显示在一起吗,我开一个灯他显示1,不开不显示
回复

使用道具 举报

25

主题

260

回帖

2045

积分

金牌会员

积分
2045
金钱
1760
HASS币
0
发表于 2023-6-16 15:26:15 | 显示全部楼层
用auto-entities:https://github.com/thomasloven/lovelace-auto-entities
前端配置如下
type: custom:auto-entities
show_empty: false
card:
  type: entities
  title: 灯光
  state_color: true
filter:
  include:
    - domain: light
      state: 'on'
      options:
        tap_action:
          action: toggle
直接呈现
回复

使用道具 举报

3

主题

130

回帖

1302

积分

金牌会员

积分
1302
金钱
1169
HASS币
0
发表于 2023-6-16 16:26:34 | 显示全部楼层
wpw72 发表于 2023-6-16 15:26
用auto-entities:https://github.com/thomasloven/lovelace-auto-entities
前端配置如下
type: custom:aut ...

auto-entities确实支持
前两天我还用button-card套用了auto-entities,也支持
回复

使用道具 举报

48

主题

607

回帖

4018

积分

论坛元老

积分
4018
金钱
3363
HASS币
30
 楼主| 发表于 2023-6-16 19:56:09 | 显示全部楼层
scabbers 发表于 2023-6-16 16:26
auto-entities确实支持
前两天我还用button-card套用了auto-entities,也支持

能否发下显示效果,是不是比自带的卡片更好看,button-card是个好东西
回复

使用道具 举报

1

主题

23

回帖

232

积分

中级会员

积分
232
金钱
208
HASS币
0
发表于 2023-11-16 01:53:38 | 显示全部楼层
wpw72 发表于 2023-6-16 15:26
用auto-entities:https://github.com/thomasloven/lovelace-auto-entities
前端配置如下
type: custom:aut ...

谢谢,完全可用,图形界面我始终编辑不了,还是代码厉害!
回复

使用道具 举报

5

主题

200

回帖

905

积分

高级会员

积分
905
金钱
700
HASS币
0
发表于 2024-2-21 19:55:48 | 显示全部楼层
marlboro 发表于 2023-11-16 01:53
谢谢,完全可用,图形界面我始终编辑不了,还是代码厉害!

我也是这个问题,UI无法编辑,代码我只能靠抄了。
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2025-5-5 11:12 , Processed in 0.066748 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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