avatar

知识便利贴

智能 · 创造

  • 首页
  • 户型图
  • NodeRed
  • HA知识
  • 硬件DIY
  • docker镜像
Home template学习
文章

template学习

Posted 2024-10-20 Updated 2024-10- 20
By 知识便利贴
1~2 min read

1、统计楼层开灯数量

{%- set ns = namespace(total_lights_on=0) %}
{%- set rooms = floor_areas('yi_lou') %}
{%- for room in rooms %}
  {%- set entities = area_entities(room) %}
  {%- for entity in entities %}
    {%- if states[entity] is not none and states[entity].domain == 'light' and states[entity].state == 'on' %}
      {%- set ns.total_lights_on = ns.total_lights_on + 1 %}
    {%- endif %}
  {%- endfor %}
{%- endfor %}
{{ ns.total_lights_on }}

2、遍历楼层实体

{%- set rooms = floor_areas('yi_lou') %}
{%- for room in rooms %}
  Room: {{ room }}
  {%- set entities = area_entities(room) %}
  {%- for entity in entities %}
    Entity: {{ entity }} - State: {{ states[entity].state if states[entity] is not none else 'unknown' }}
  {%- endfor %}
{%- endfor %}

homeassistant
homeassistant
License:  CC BY 4.0
Share

Further Reading

Oct 20, 2024

template学习

1、统计楼层开灯数量 {%- set ns = namespace(total_lights_on=0) %} {%- set rooms = floor_areas('yi_lou') %} {%- for room in rooms %} {%- set entities = area_en

OLDER

智能电表烧录教程

NEWER

npm学习笔记

Recently Updated

  • 不明原因磁盘爆满排查记录
  • AI读表设置教程
  • zigbee有线网关DIY
  • npm学习笔记
  • template学习

Trending Tags

homeassistant 智能电表 esphome Halo

Contents