HA的 templates 页面指引

1、查看所有HA接入设备id及属性
在HA中的 templates 页面中输入以下代码:

  1. {{ "_".ljust(90, "_") }}
  2. {%- set domains = [states.light, states.switch, states.automation, states.device_tracker, states.group, states.media_player, states.proximity, states.script, states.zone, states.zwave, states.binary_sensor, states.sensor, states.calendar ] %}
  3. {{ "Entity ID".ljust(50) }}{{ "Entity Name" }}
  4. {{ "Attribute Name".ljust(50) }}{{ "Attribute Value" }}
  5. {%- for domain in domains -%}
  6. {% for item in domain %}
  7. {{ "_".ljust(90, "_") }}
  8. {{ item.entity_id.ljust(50) }}
  9. {{ "State".ljust(50) }}: {{ item.state}}
  10. {{ "Domain".ljust(50) }}: {{ item.domain}}
  11. {{ "Object ID".ljust(50) }}: {{ item.object_id}}
  12. {{ "Last Updated".ljust(50) }}: {{ item.last_updated}}
  13. {{ "Last Changed".ljust(50) }}: {{ item.last_changed}}
  14. {%- for attrib in item.attributes|sort() %}
  15. {%- if attrib is defined %}
  16. {{attrib.ljust(50)}}: {{ item.attributes[attrib] }}
  17. {%- endif %}
  18. {%- endfor %}
  19. {%- endfor %}
  20. {%- endfor %}

2、只查看所有HA接入设备id,不含属性
在HA中的 templates 页面中输入以下代码:

  1. {%- set domains = [states.light, states.switch, states.automation, states.device_tracker, states.group, states.media_player, states.proximity, states.script, states.zone, states.zwave, states.binary_sensor, states.sensor, states.calendar ] %}
  2. {{ "Entity ID".ljust(50) }} {{ "Entity Name" }}
  3. {%- for domain in domains %}
  4. {% for item in domain %}
  5. {{ item.entity_id.ljust(50) }} {{ item.name }}
  6. {%- endfor %}
  7. {%- endfor %}

文档更新时间: 2017-09-08 12:30   作者:admin