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

[技术探讨] 模版解惑

[复制链接]

25

主题

260

回帖

2057

积分

金牌会员

积分
2057
金钱
1772
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就不能实现功能,请大神分析下原因,不胜感谢。

回复

使用道具 举报

jjcs 手机认证

51

主题

1923

回帖

7785

积分

论坛元老

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

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-5-15 01:23 , Processed in 0.416045 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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