various package updates
This commit is contained in:
+270
-127
@@ -1,32 +1,35 @@
|
||||
# =====================================================================
|
||||
# Home Assistant Summary - package (ESPHome, Tasmota, ZHA, Zigbee2MQTT)
|
||||
# Robust Z2M detection using device identifiers containing "zigbee2mqtt".
|
||||
# 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:
|
||||
- trigger:
|
||||
- platform: event
|
||||
event_type: homeassistant_started
|
||||
- platform: event
|
||||
event_type: entity_registry_updated
|
||||
- platform: event
|
||||
event_type: device_registry_updated
|
||||
- platform: event
|
||||
event_type: area_registry_updated
|
||||
- platform: event
|
||||
event_type: core_config_updated
|
||||
- platform: time_pattern
|
||||
minutes: "/5"
|
||||
|
||||
sensor:
|
||||
- sensor:
|
||||
# ---------- Totals and basics ----------
|
||||
- name: HA Summary - entities total
|
||||
unique_id: ha_summary_entities_total
|
||||
state: "{{ states | list | length }}"
|
||||
unit_of_measurement: "entities"
|
||||
|
||||
- name: HA Summary - devices total
|
||||
unique_id: ha_summary_devices_total
|
||||
unit_of_measurement: "devices"
|
||||
state: >-
|
||||
{% set ids = namespace(v=[]) %}
|
||||
{% for s in states %}
|
||||
@@ -36,23 +39,27 @@ template:
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ ids.v | length }}
|
||||
unit_of_measurement: "devices"
|
||||
|
||||
- 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 }}
|
||||
unit_of_measurement: "entities"
|
||||
|
||||
- name: HA Summary - cameras
|
||||
unique_id: ha_summary_cameras
|
||||
state: "{{ states.camera | list | length }}"
|
||||
unit_of_measurement: "cameras"
|
||||
state: "{{ states.camera | list | length }}"
|
||||
|
||||
- name: HA Summary - areas
|
||||
unique_id: ha_summary_areas
|
||||
state: "{{ areas() | list | length }}"
|
||||
unit_of_measurement: "areas"
|
||||
state: "{{ areas() | list | length }}"
|
||||
|
||||
- name: HA Summary - scenes
|
||||
unique_id: ha_summary_scenes
|
||||
@@ -66,13 +73,41 @@ template:
|
||||
unique_id: ha_summary_automations
|
||||
state: "{{ states.automation | list | length }}"
|
||||
|
||||
# ---------- ESPHome ----------
|
||||
- name: HA Summary - esphome entities
|
||||
unique_id: ha_summary_esphome_entities
|
||||
state: "{{ integration_entities('esphome') | 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') %}
|
||||
@@ -83,13 +118,15 @@ template:
|
||||
{% endfor %}
|
||||
{{ ids.v | length }}
|
||||
|
||||
# ---------- Tasmota ----------
|
||||
- name: HA Summary - tasmota entities
|
||||
unique_id: ha_summary_tasmota_entities
|
||||
state: "{{ integration_entities('tasmota') | list | 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') %}
|
||||
@@ -100,13 +137,15 @@ template:
|
||||
{% endfor %}
|
||||
{{ ids.v | length }}
|
||||
|
||||
# ---------- Zigbee via ZHA ----------
|
||||
- name: HA Summary - zha entities
|
||||
unique_id: ha_summary_zha_entities
|
||||
state: "{{ integration_entities('zha') | list | length }}"
|
||||
- name: HA Summary - tasmota entities
|
||||
unique_id: ha_summary_tasmota_entities
|
||||
unit_of_measurement: "entities"
|
||||
state: "{{ integration_entities('tasmota') | list | length }}"
|
||||
|
||||
- name: HA Summary - zha devices
|
||||
unique_id: ha_summary_zha_devices
|
||||
# ---------- 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') %}
|
||||
@@ -117,77 +156,191 @@ template:
|
||||
{% endfor %}
|
||||
{{ ids.v | length }}
|
||||
|
||||
# ---------- Zigbee via Zigbee2MQTT (robust) ----------
|
||||
# Match if device identifiers mention "zigbee2mqtt".
|
||||
# Fallbacks: entity_id or unique_id contains "zigbee2mqtt" or ".z2m_".
|
||||
- name: HA Summary - z2m entities
|
||||
unique_id: ha_summary_z2m_entities
|
||||
state: >-
|
||||
{% set ent = namespace(v=[]) %}
|
||||
{% for s in states %}
|
||||
{% set eid = s.entity_id %}
|
||||
{% set did = device_id(eid) %}
|
||||
{% set match = false %}
|
||||
{% if did %}
|
||||
{% set ident = device_attr(did,'identifiers') | default([], true) %}
|
||||
{% if (ident | string | lower) | regex_search('zigbee2mqtt') %}
|
||||
{% set match = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if not match %}
|
||||
{% set uid = state_attr(eid,'unique_id') | default('', true) | string | lower %}
|
||||
{% if 'zigbee2mqtt' in eid or '.z2m_' in eid or 'zigbee2mqtt' in uid %}
|
||||
{% set match = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if match %}
|
||||
{% set ent.v = ent.v + [eid] %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ ent.v | unique | list | length }}
|
||||
- name: HA Summary - zigbee zha entities
|
||||
unique_id: ha_summary_zigbee_zha_entities
|
||||
unit_of_measurement: "entities"
|
||||
state: "{{ integration_entities('zha') | list | length }}"
|
||||
|
||||
- name: HA Summary - z2m devices
|
||||
unique_id: ha_summary_z2m_devices
|
||||
# ---------- 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 s in states %}
|
||||
{% set eid = s.entity_id %}
|
||||
{% set did = device_id(eid) %}
|
||||
{% for e in integration_entities('mqtt') | list %}
|
||||
{% set did = device_id(e) %}
|
||||
{% if did and did not in dids.v %}
|
||||
{% set ident = device_attr(did,'identifiers') | default([], true) %}
|
||||
{% set uid = state_attr(eid,'unique_id') | default('', true) | string | lower %}
|
||||
{% if (ident | string | lower) | regex_search('zigbee2mqtt') or
|
||||
'zigbee2mqtt' in eid or '.z2m_' in eid or 'zigbee2mqtt' in uid %}
|
||||
{% 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 }}
|
||||
|
||||
# ---------- Cloud devices/entities (edit list as desired) ----------
|
||||
- name: HA Summary - cloud entities
|
||||
unique_id: ha_summary_cloud_entities
|
||||
- name: HA Summary - zigbee z2m entities
|
||||
unique_id: ha_summary_zigbee_z2m_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 }}
|
||||
{% 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 (
|
||||
@@ -213,34 +366,24 @@ template:
|
||||
{% endfor %}
|
||||
{{ dids.v | length }}
|
||||
|
||||
# ---------- Supervisor add-ons (approximate) ----------
|
||||
# Union of: update entities in hassio integration + updates attributed to Supervisor.
|
||||
- name: HA Summary - addons
|
||||
unique_id: ha_summary_addons
|
||||
icon: mdi:puzzle
|
||||
- name: HA Summary - cloud entities
|
||||
unique_id: ha_summary_cloud_entities
|
||||
unit_of_measurement: "entities"
|
||||
state: >-
|
||||
{% set hassio_updates = (integration_entities('hassio') | list) %}
|
||||
{% set a = states.update
|
||||
| selectattr('entity_id','in', hassio_updates)
|
||||
| map(attribute='entity_id')
|
||||
| list %}
|
||||
{% set b = states.update
|
||||
| selectattr('attributes.attribution','defined')
|
||||
| selectattr('attributes.attribution','search','Supervisor')
|
||||
| map(attribute='entity_id')
|
||||
| list %}
|
||||
{% set ids = (a + b)
|
||||
| unique
|
||||
| reject('search','^update\\.home_assistant_(core|supervisor|operating_system)_update$')
|
||||
| list %}
|
||||
{{ ids | length }}
|
||||
|
||||
# ---------- HACS updates available (proxy only) ----------
|
||||
- name: HA Summary - hacs updates
|
||||
unique_id: ha_summary_hacs_updates
|
||||
icon: mdi:download
|
||||
state: >-
|
||||
{{ states.update
|
||||
| selectattr('state','eq','on')
|
||||
| rejectattr('attributes.in_progress','true')
|
||||
| list | length }}
|
||||
{% 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 }}
|
||||
|
||||
Reference in New Issue
Block a user