390 lines
15 KiB
YAML
390 lines
15 KiB
YAML
# =====================================================================
|
|
# Home Assistant Summary - package
|
|
#
|
|
# Counts:
|
|
# - Total devices/entities/broken entities
|
|
# - Cameras, areas, scenes, scripts, automations
|
|
# - ESPHome devices/entities
|
|
# - Tasmota devices/entities
|
|
# - Zigbee ZHA devices/entities
|
|
# - Zigbee2MQTT devices/entities
|
|
# - Matter devices/entities
|
|
# - Matter Wi-Fi/Ethernet devices/entities - best effort
|
|
# - Matter Thread devices/entities - best effort
|
|
# - Matter unclassified devices/entities
|
|
# - Cloud-ish devices/entities
|
|
# - Supervisor add-ons - approximate
|
|
# - Updates available
|
|
#
|
|
# Important:
|
|
# - This uses only modern template: syntax.
|
|
# - There must be no root-level:
|
|
# sensor:
|
|
# - platform: template
|
|
# in this package.
|
|
# =====================================================================
|
|
|
|
template:
|
|
- sensor:
|
|
# ---------- Totals and basics ----------
|
|
- name: HA Summary - devices total
|
|
unique_id: ha_summary_devices_total
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set ids = namespace(v=[]) %}
|
|
{% for s in states %}
|
|
{% set did = device_id(s.entity_id) %}
|
|
{% if did and did not in ids.v %}
|
|
{% set ids.v = ids.v + [did] %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ids.v | length }}
|
|
|
|
- name: HA Summary - entities total
|
|
unique_id: ha_summary_entities_total
|
|
unit_of_measurement: "entities"
|
|
state: "{{ states | list | length }}"
|
|
|
|
- name: HA Summary - entities broken
|
|
unique_id: ha_summary_entities_broken
|
|
unit_of_measurement: "entities"
|
|
state: >-
|
|
{{ states | selectattr('state','in',['unavailable','unknown']) | list | length }}
|
|
|
|
- name: HA Summary - cameras
|
|
unique_id: ha_summary_cameras
|
|
unit_of_measurement: "cameras"
|
|
state: "{{ states.camera | list | length }}"
|
|
|
|
- name: HA Summary - areas
|
|
unique_id: ha_summary_areas
|
|
unit_of_measurement: "areas"
|
|
state: "{{ areas() | list | length }}"
|
|
|
|
- name: HA Summary - scenes
|
|
unique_id: ha_summary_scenes
|
|
state: "{{ states.scene | list | length }}"
|
|
|
|
- name: HA Summary - scripts
|
|
unique_id: ha_summary_scripts
|
|
state: "{{ states.script | list | length }}"
|
|
|
|
- name: HA Summary - automations
|
|
unique_id: ha_summary_automations
|
|
state: "{{ states.automation | list | length }}"
|
|
|
|
# ---------- Add-ons and updates ----------
|
|
- name: HA Summary - addons
|
|
unique_id: ha_summary_addons
|
|
icon: mdi:puzzle
|
|
state: >-
|
|
{% set hassio_entities = integration_entities('hassio') | list %}
|
|
{% set skip = [
|
|
'update.home_assistant_core_update',
|
|
'update.home_assistant_supervisor_update',
|
|
'update.home_assistant_operating_system_update'
|
|
] %}
|
|
{% set count = namespace(v=0) %}
|
|
{% for u in states.update %}
|
|
{% if u.entity_id in hassio_entities and u.entity_id not in skip %}
|
|
{% set count.v = count.v + 1 %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ count.v }}
|
|
|
|
- name: HA Summary - hacs updates
|
|
unique_id: ha_summary_hacs_updates
|
|
icon: mdi:download
|
|
state: >-
|
|
{% set count = namespace(v=0) %}
|
|
{% for u in states.update %}
|
|
{% if u.state == 'on' and not (u.attributes.in_progress | default(false)) %}
|
|
{% set count.v = count.v + 1 %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ count.v }}
|
|
|
|
# ---------- ESPHome ----------
|
|
- name: HA Summary - esphome devices
|
|
unique_id: ha_summary_esphome_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set ids = namespace(v=[]) %}
|
|
{% for e in integration_entities('esphome') %}
|
|
{% set did = device_id(e) %}
|
|
{% if did and did not in ids.v %}
|
|
{% set ids.v = ids.v + [did] %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ids.v | length }}
|
|
|
|
- name: HA Summary - esphome entities
|
|
unique_id: ha_summary_esphome_entities
|
|
unit_of_measurement: "entities"
|
|
state: "{{ integration_entities('esphome') | list | length }}"
|
|
|
|
# ---------- Tasmota ----------
|
|
- name: HA Summary - tasmota devices
|
|
unique_id: ha_summary_tasmota_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set ids = namespace(v=[]) %}
|
|
{% for e in integration_entities('tasmota') %}
|
|
{% set did = device_id(e) %}
|
|
{% if did and did not in ids.v %}
|
|
{% set ids.v = ids.v + [did] %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ids.v | length }}
|
|
|
|
- name: HA Summary - tasmota entities
|
|
unique_id: ha_summary_tasmota_entities
|
|
unit_of_measurement: "entities"
|
|
state: "{{ integration_entities('tasmota') | list | length }}"
|
|
|
|
# ---------- Zigbee via ZHA ----------
|
|
- name: HA Summary - zigbee zha devices
|
|
unique_id: ha_summary_zigbee_zha_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set ids = namespace(v=[]) %}
|
|
{% for e in integration_entities('zha') %}
|
|
{% set did = device_id(e) %}
|
|
{% if did and did not in ids.v %}
|
|
{% set ids.v = ids.v + [did] %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ids.v | length }}
|
|
|
|
- name: HA Summary - zigbee zha entities
|
|
unique_id: ha_summary_zigbee_zha_entities
|
|
unit_of_measurement: "entities"
|
|
state: "{{ integration_entities('zha') | list | length }}"
|
|
|
|
# ---------- Zigbee via Zigbee2MQTT ----------
|
|
# This counts MQTT entities whose Home Assistant device identifiers
|
|
# include "zigbee2mqtt". This should catch devices with clean entity IDs
|
|
# like sensor.lounge_blind_b_xbl12_battery.
|
|
- name: HA Summary - zigbee z2m devices
|
|
unique_id: ha_summary_zigbee_z2m_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set dids = namespace(v=[]) %}
|
|
{% for e in integration_entities('mqtt') | list %}
|
|
{% set did = device_id(e) %}
|
|
{% if did and did not in dids.v %}
|
|
{% set txt = (
|
|
((device_attr(did, 'identifiers') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'connections') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'name') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'model') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'manufacturer') or '') | string)
|
|
) | lower %}
|
|
{% if 'zigbee2mqtt' in txt %}
|
|
{% set dids.v = dids.v + [did] %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ dids.v | length }}
|
|
|
|
- name: HA Summary - zigbee z2m entities
|
|
unique_id: ha_summary_zigbee_z2m_entities
|
|
unit_of_measurement: "entities"
|
|
state: >-
|
|
{% set ent = namespace(v=[]) %}
|
|
{% for e in integration_entities('mqtt') | list %}
|
|
{% set did = device_id(e) %}
|
|
{% if did %}
|
|
{% set txt = (
|
|
((device_attr(did, 'identifiers') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'connections') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'name') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'model') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'manufacturer') or '') | string)
|
|
) | lower %}
|
|
{% if 'zigbee2mqtt' in txt %}
|
|
{% set ent.v = ent.v + [e] %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ent.v | unique | list | length }}
|
|
|
|
# ---------- Matter total ----------
|
|
- name: HA Summary - matter devices
|
|
unique_id: ha_summary_matter_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set ids = namespace(v=[]) %}
|
|
{% for e in integration_entities('matter') %}
|
|
{% set did = device_id(e) %}
|
|
{% if did and did not in ids.v %}
|
|
{% set ids.v = ids.v + [did] %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ids.v | length }}
|
|
|
|
- name: HA Summary - matter entities
|
|
unique_id: ha_summary_matter_entities
|
|
unit_of_measurement: "entities"
|
|
state: "{{ integration_entities('matter') | list | length }}"
|
|
|
|
# ---------- Matter over Wi-Fi / Ethernet - best effort ----------
|
|
- name: HA Summary - matter wifi devices
|
|
unique_id: ha_summary_matter_wifi_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set dids = namespace(v=[]) %}
|
|
{% for e in integration_entities('matter') %}
|
|
{% set did = device_id(e) %}
|
|
{% if did and did not in dids.v %}
|
|
{% set txt = (
|
|
((device_attr(did, 'identifiers') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'connections') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'name') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'model') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'manufacturer') or '') | string)
|
|
) | lower %}
|
|
{% if 'wifi' in txt or 'wi-fi' in txt or 'wlan' in txt or 'ethernet' in txt %}
|
|
{% set dids.v = dids.v + [did] %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ dids.v | length }}
|
|
|
|
- name: HA Summary - matter wifi entities
|
|
unique_id: ha_summary_matter_wifi_entities
|
|
unit_of_measurement: "entities"
|
|
state: >-
|
|
{% set ent = namespace(v=[]) %}
|
|
{% for e in integration_entities('matter') %}
|
|
{% set did = device_id(e) %}
|
|
{% if did %}
|
|
{% set txt = (
|
|
((device_attr(did, 'identifiers') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'connections') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'name') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'model') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'manufacturer') or '') | string)
|
|
) | lower %}
|
|
{% if 'wifi' in txt or 'wi-fi' in txt or 'wlan' in txt or 'ethernet' in txt %}
|
|
{% set ent.v = ent.v + [e] %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ent.v | unique | list | length }}
|
|
|
|
# ---------- Matter over Thread - best effort ----------
|
|
- name: HA Summary - matter thread devices
|
|
unique_id: ha_summary_matter_thread_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set dids = namespace(v=[]) %}
|
|
{% for e in integration_entities('matter') %}
|
|
{% set did = device_id(e) %}
|
|
{% if did and did not in dids.v %}
|
|
{% set txt = (
|
|
((device_attr(did, 'identifiers') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'connections') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'name') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'model') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'manufacturer') or '') | string)
|
|
) | lower %}
|
|
{% if 'thread' in txt or 'openthread' in txt or 'otbr' in txt or 'border router' in txt or 'border-router' in txt or '802.15.4' in txt %}
|
|
{% set dids.v = dids.v + [did] %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ dids.v | length }}
|
|
|
|
- name: HA Summary - matter thread entities
|
|
unique_id: ha_summary_matter_thread_entities
|
|
unit_of_measurement: "entities"
|
|
state: >-
|
|
{% set ent = namespace(v=[]) %}
|
|
{% for e in integration_entities('matter') %}
|
|
{% set did = device_id(e) %}
|
|
{% if did %}
|
|
{% set txt = (
|
|
((device_attr(did, 'identifiers') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'connections') or []) | string) ~ ' ' ~
|
|
((device_attr(did, 'name') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'model') or '') | string) ~ ' ' ~
|
|
((device_attr(did, 'manufacturer') or '') | string)
|
|
) | lower %}
|
|
{% if 'thread' in txt or 'openthread' in txt or 'otbr' in txt or 'border router' in txt or 'border-router' in txt or '802.15.4' in txt %}
|
|
{% set ent.v = ent.v + [e] %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ent.v | unique | list | length }}
|
|
|
|
# ---------- Matter unclassified ----------
|
|
- name: HA Summary - matter unclassified devices
|
|
unique_id: ha_summary_matter_unclassified_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set total = states('sensor.ha_summary_matter_devices') | int(0) %}
|
|
{% set wifi = states('sensor.ha_summary_matter_wifi_devices') | int(0) %}
|
|
{% set thread = states('sensor.ha_summary_matter_thread_devices') | int(0) %}
|
|
{{ [total - wifi - thread, 0] | max }}
|
|
|
|
- name: HA Summary - matter unclassified entities
|
|
unique_id: ha_summary_matter_unclassified_entities
|
|
unit_of_measurement: "entities"
|
|
state: >-
|
|
{% set total = states('sensor.ha_summary_matter_entities') | int(0) %}
|
|
{% set wifi = states('sensor.ha_summary_matter_wifi_entities') | int(0) %}
|
|
{% set thread = states('sensor.ha_summary_matter_thread_entities') | int(0) %}
|
|
{{ [total - wifi - thread, 0] | max }}
|
|
|
|
# ---------- Cloud devices/entities ----------
|
|
- name: HA Summary - cloud devices
|
|
unique_id: ha_summary_cloud_devices
|
|
unit_of_measurement: "devices"
|
|
state: >-
|
|
{% set dids = namespace(v=[]) %}
|
|
{% for e in (
|
|
integration_entities('tuya') +
|
|
integration_entities('ewelink') +
|
|
integration_entities('meross_cloud') +
|
|
integration_entities('tapo') +
|
|
integration_entities('tplink') +
|
|
integration_entities('nest') +
|
|
integration_entities('ring') +
|
|
integration_entities('arlo') +
|
|
integration_entities('wyze') +
|
|
integration_entities('myq') +
|
|
integration_entities('nuki') +
|
|
integration_entities('august') +
|
|
integration_entities('switchbot') +
|
|
integration_entities('icloud')
|
|
) | unique %}
|
|
{% set did = device_id(e) %}
|
|
{% if did and did not in dids.v %}
|
|
{% set dids.v = dids.v + [did] %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ dids.v | length }}
|
|
|
|
- name: HA Summary - cloud entities
|
|
unique_id: ha_summary_cloud_entities
|
|
unit_of_measurement: "entities"
|
|
state: >-
|
|
{% set list_all =
|
|
integration_entities('tuya') +
|
|
integration_entities('ewelink') +
|
|
integration_entities('meross_cloud') +
|
|
integration_entities('tapo') +
|
|
integration_entities('tplink') +
|
|
integration_entities('nest') +
|
|
integration_entities('ring') +
|
|
integration_entities('arlo') +
|
|
integration_entities('wyze') +
|
|
integration_entities('myq') +
|
|
integration_entities('nuki') +
|
|
integration_entities('august') +
|
|
integration_entities('switchbot') +
|
|
integration_entities('icloud')
|
|
%}
|
|
{{ list_all | unique | list | length }}
|