@ -1,12 +1,13 @@
#-------------------------------------------
######################################################################
# @CCOSTAN
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Stats - Historical metrics and AI notifications.
# Stats - Historical metrics and AI notifications.
# -------------------------------------------
# Build historical stats for AI/alerting.
# #####################################################################
# -------------------------------------------------------------------
# # Build historical stats for AI/alerting.
# Contact: @CCOSTAN
######################################################################
######################################################################
# Find me on X @CCOSTAN
### Building out some Historical stats for AI. #####################
### Building out some Historical stats for AI. #####################
command_line:
command_line:
@ -71,51 +72,56 @@ sensor:
days : 7
days : 7
### Building some interesting stats for tweeting. ###
### Building some interesting stats for tweeting. ###
- platform : template
sensors:
template:
sensor_count:
- sensor:
friendly_name : 'Number of Sensors'
- name : "Number of Sensors"
value_template : >-
unique_id : stats_number_of_sensors
unit_of_measurement : "count"
icon : mdi:counter
state : >-
{{ states.sensor | list | count }}
{{ states.sensor | list | count }}
unit_of_measurement : 'count'
icon_template : mdi:counter
automation_count:
- name : "Number of Automations"
friendly_name : 'Number of Automations'
unique_id : stats_number_of_automations
value_template : >-
unit_of_measurement : "count"
icon : mdi:robot
state : >-
{{ states.automation | list | count }}
{{ states.automation | list | count }}
unit_of_measurement : 'count'
icon_template : mdi:robot
script_count:
- name : "Number of Scripts"
friendly_name : 'Number of Scripts'
unique_id : stats_number_of_scripts
value_template : >-
unit_of_measurement : "count"
icon : mdi:script-text
state : >-
{{ states.script | list | count }}
{{ states.script | list | count }}
unit_of_measurement : 'count'
icon_template : mdi:script-text
binary_sensor_count:
- name : "Number of Binary Sensors"
friendly_name : 'Number of Binary Sensors'
unique_id : stats_number_of_binary_sensors
value_template : >-
unit_of_measurement : "count"
icon : mdi:binary-sensor
state : >-
{{ states.binary_sensor | list | count }}
{{ states.binary_sensor | list | count }}
unit_of_measurement : 'count'
icon_template : mdi:binary-sensor
- name : "Number of Devices"
tracker_count:
unique_id : stats_number_of_devices
friendly_name : 'Number of Devices'
unit_of_measurement : "count"
value_template : >-
icon : mdi:account-group
{{ states.device_tracker| list | count }}
state : >-
unit_of_measurement : 'count'
{{ states.device_tracker | list | count }}
icon_template : mdi:account-group
- name : "Number of Lights"
lights_count:
unique_id : stats_number_of_lights
friendly_name : 'Number of Lights'
unit_of_measurement : "count"
value_template : >
icon : mdi:lightbulb
state : >
{{ states.light | list | count }}
{{ states.light | list | count }}
unit_of_measurement : 'count'
icon_template : mdi:lightbulb
- name : "Number of lights on"
lights_on_count:
unique_id : stats_number_of_lights_on
friendly_name : "Number of lights on"
unit_of_measurement : "count"
value_template : >-
icon : mdi:binary-sensor
state : >-
{% set lights = states.light | selectattr('state', 'eq', 'on') | list %}
{% set lights = states.light | selectattr('state', 'eq', 'on') | list %}
{% set qty = lights | count %}
{% set qty = lights | count %}
{% set p1 = 'lights are' if qty > 1 else 'light is' %}
{% set p1 = 'lights are' if qty > 1 else 'light is' %}
@ -125,11 +131,11 @@ sensor:
{% else %}
{% else %}
{{ qty }} {{ p1 }} on.
{{ qty }} {{ p1 }} on.
{% endif %}
{% endif %}
unit_of_measurement : 'count'
icon_template : mdi:binary-sensor
- name : "Number of Smoke Detectors"
protect_count:
unit_of_measurement : "count"
friendly_name: 'Number of Smoke Detectors'
icon: mdi:smoke-detector
value_templ ate: >
st ate: >
{% if states('group.protects') == 'on' %}
{% if states('group.protects') == 'on' %}
{% for e in states.group.protects.attributes.entity_id if states(e) == 'on' %}
{% for e in states.group.protects.attributes.entity_id if states(e) == 'on' %}
{% if loop.last %}
{% if loop.last %}
@ -139,20 +145,19 @@ sensor:
{% else %}
{% else %}
0
0
{% endif %}
{% endif %}
unit_of_measurement : 'count'
icon_template : mdi:smoke-detector
- name : "Number of online Cameras"
camera_count:
unique_id : stats_number_of_online_cameras
friendly_name : 'Number of online Cameras'
unit_of_measurement : "count"
value_template : >
icon : mdi:camera
state : >
{{ states.camera | list | count }}
{{ states.camera | list | count }}
unit_of_measurement : 'count'
icon_template : mdi:camera
- name : "Total WiFi Clients"
total_wifi_clients:
friendly_name : "Total WiFi Clients"
unique_id : total_wifi_clients
unique_id : total_wifi_clients
unit_of_measurement : "clients"
unit_of_measurement : "clients"
icon _template : mdi:wifi
icon : mdi:wifi
value_templ ate: >
st ate: >
{% set g = states('sensor.unifi_ap_garage_clients') | int(0) %}
{% set g = states('sensor.unifi_ap_garage_clients') | int(0) %}
{% set o = states('sensor.unifi_ap_office_clients') | int(0) %}
{% set o = states('sensor.unifi_ap_office_clients') | int(0) %}
{% set s = states('sensor.unifi_ap_study_clients') | int(0) %}
{% set s = states('sensor.unifi_ap_study_clients') | int(0) %}