1- # -------------------------------------------
2- # @CCOSTAN
1+ # #####################################################################
2+ # @CCOSTAN - Follow Me on X
3+ # For more info visit https://www.vcloudinfo.com/click-here
34# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
5+ # -------------------------------------------------------------------
46# Stats - Historical metrics and AI notifications.
5- # -------------------------------------------
6- # #####################################################################
7- # # Build historical stats for AI/alerting.
7+ # Build historical stats for AI/alerting.
8+ # -------------------------------------------------------------------
9+ # Contact: @CCOSTAN
810# #####################################################################
9- # Find me on X @CCOSTAN
1011
1112# ## Building out some Historical stats for AI. #####################
1213command_line :
@@ -71,51 +72,56 @@ sensor:
7172 days : 7
7273
7374# ## Building some interesting stats for tweeting. ###
74- - platform : template
75- sensors :
76- sensor_count :
77- friendly_name : ' Number of Sensors'
78- value_template : >-
75+
76+ template :
77+ - sensor :
78+ - name : " Number of Sensors"
79+ unique_id : stats_number_of_sensors
80+ unit_of_measurement : " count"
81+ icon : mdi:counter
82+ state : >-
7983 {{ states.sensor | list | count }}
80- unit_of_measurement : ' count'
81- icon_template : mdi:counter
8284
83- automation_count :
84- friendly_name : ' Number of Automations'
85- value_template : >-
85+ - name : " Number of Automations"
86+ unique_id : stats_number_of_automations
87+ unit_of_measurement : " count"
88+ icon : mdi:robot
89+ state : >-
8690 {{ states.automation | list | count }}
87- unit_of_measurement : ' count'
88- icon_template : mdi:robot
8991
90- script_count :
91- friendly_name : ' Number of Scripts'
92- value_template : >-
92+ - name : " Number of Scripts"
93+ unique_id : stats_number_of_scripts
94+ unit_of_measurement : " count"
95+ icon : mdi:script-text
96+ state : >-
9397 {{ states.script | list | count }}
94- unit_of_measurement : ' count'
95- icon_template : mdi:script-text
9698
97- binary_sensor_count :
98- friendly_name : ' Number of Binary Sensors'
99- value_template : >-
99+ - name : " Number of Binary Sensors"
100+ unique_id : stats_number_of_binary_sensors
101+ unit_of_measurement : " count"
102+ icon : mdi:binary-sensor
103+ state : >-
100104 {{ states.binary_sensor | list | count }}
101- unit_of_measurement : ' count'
102- icon_template : mdi:binary-sensor
103- tracker_count :
104- friendly_name : ' Number of Devices'
105- value_template : >-
106- {{ states.device_tracker| list | count }}
107- unit_of_measurement : ' count'
108- icon_template : mdi:account-group
109-
110- lights_count :
111- friendly_name : ' Number of Lights'
112- value_template : >
105+
106+ - name : " Number of Devices"
107+ unique_id : stats_number_of_devices
108+ unit_of_measurement : " count"
109+ icon : mdi:account-group
110+ state : >-
111+ {{ states.device_tracker | list | count }}
112+
113+ - name : " Number of Lights"
114+ unique_id : stats_number_of_lights
115+ unit_of_measurement : " count"
116+ icon : mdi:lightbulb
117+ state : >
113118 {{ states.light | list | count }}
114- unit_of_measurement : ' count'
115- icon_template : mdi:lightbulb
116- lights_on_count :
117- friendly_name : " Number of lights on"
118- value_template : >-
119+
120+ - name : " Number of lights on"
121+ unique_id : stats_number_of_lights_on
122+ unit_of_measurement : " count"
123+ icon : mdi:binary-sensor
124+ state : >-
119125 {% set lights = states.light | selectattr('state', 'eq', 'on') | list %}
120126 {% set qty = lights | count %}
121127 {% set p1 = 'lights are' if qty > 1 else 'light is' %}
@@ -125,11 +131,11 @@ sensor:
125131 {% else %}
126132 {{ qty }} {{ p1 }} on.
127133 {% endif %}
128- unit_of_measurement : ' count '
129- icon_template : mdi:binary-sensor
130- protect_count :
131- friendly_name : ' Number of Smoke Detectors '
132- value_template : >
134+
135+ - name : " Number of Smoke Detectors "
136+ unit_of_measurement : " count "
137+ icon : mdi:smoke-detector
138+ state : >
133139 {% if states('group.protects') == 'on' %}
134140 {% for e in states.group.protects.attributes.entity_id if states(e) == 'on' %}
135141 {% if loop.last %}
@@ -139,20 +145,19 @@ sensor:
139145 {% else %}
140146 0
141147 {% endif %}
142- unit_of_measurement : ' count'
143- icon_template : mdi:smoke-detector
144- camera_count :
145- friendly_name : ' Number of online Cameras'
146- value_template : >
148+
149+ - name : " Number of online Cameras"
150+ unique_id : stats_number_of_online_cameras
151+ unit_of_measurement : " count"
152+ icon : mdi:camera
153+ state : >
147154 {{ states.camera | list | count }}
148- unit_of_measurement : ' count'
149- icon_template : mdi:camera
150- total_wifi_clients :
151- friendly_name : " Total WiFi Clients"
155+
156+ - name : " Total WiFi Clients"
152157 unique_id : total_wifi_clients
153158 unit_of_measurement : " clients"
154- icon_template : mdi:wifi
155- value_template : >
159+ icon : mdi:wifi
160+ state : >
156161 {% set g = states('sensor.unifi_ap_garage_clients') | int(0) %}
157162 {% set o = states('sensor.unifi_ap_office_clients') | int(0) %}
158163 {% set s = states('sensor.unifi_ap_study_clients') | int(0) %}
0 commit comments