『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 197|回复: 1

[技术探讨] 模版解惑

[复制链接]

16

主题

142

帖子

1203

积分

金牌会员

Rank: 6Rank: 6

积分
1203
金钱
1061
HASS币
0
发表于 2024-4-4 21:18:39 | 显示全部楼层 |阅读模式
{%- set find_integration = 'xiaomi_gateway3' %}
{%- set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
{%- set ns = namespace(entities = []) %}
{%- for device in devices %}
  {%- set ids = device_attr(device, 'identifiers') | list | first | default %}
  {%- if ids and ids | length == 2 and ids[0] == find_integration %}
    {%- set ns.entities = ns.entities + [ids[1]] %}
  {%- endif %}
{%- endfor %}
{{ ns.entities |count }}
-------
以上模版可以查询xiaomi_gateway3集成下的设备数量,将xiaomi_gateway3改成xiaomi_miot、zha、tuya、sonoff夜都能实现功能,但换成esphome就不能实现功能,请大神分析下原因,不胜感谢。

回复

使用道具 举报

41

主题

1300

帖子

5346

积分

论坛元老

Rank: 8Rank: 8

积分
5346
金钱
4041
HASS币
20
发表于 2024-4-4 21:41:23 | 显示全部楼层
那得·看·人家查询的函数支不支持
折腾精神永存,感恩感谢论坛每一位愿意分享和帮助过我的大佬,论坛有你更精彩
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-3 16:44 , Processed in 0.319105 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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