Files
Home-AssistantConfig/config/packages/stats.yaml
Carlo Costanzo c464073a0d Standardizing on Headers for all YAML files.
- Updated comments in various YAML configuration files to provide clearer descriptions of functionalities and integrations.
- Improved documentation for alarm, alexa_media_player, backups, blink, cbyge, climate, finance, fridge, garadget, glances, hass_agent_homepc, holiday, ios, landscape_lighting, lightning, logger, medicine, nfc_tags, noonhome, office_motion, phynplus, powerwall, printer, processmonitor, proxmox, rachio, rheem_econet, roku, sleepiq, space, speedtest, stats, superbowl, vacuum, wireless, and youtube packages.
- Added relevant links and issue references where applicable to enhance user guidance and support.
2025-11-29 13:17:07 -05:00

160 lines
5.0 KiB
YAML
Executable File

#-------------------------------------------
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# Stats - Historical metrics and AI notifications.
#-------------------------------------------
######################################################################
## Build historical stats for AI/alerting.
######################################################################
# Find me on X @CCOSTAN
### Building out some Historical stats for AI. #####################
command_line:
- sensor:
name: 'Lines of Code'
unique_id: lines_of_code
command: "find /config -name '*.yaml' | xargs cat | wc -l"
scan_interval: 20000
value_template: "{{ value | int }}"
unit_of_measurement: "count"
- sensor:
name: 'GitHub Open Issues'
unique_id: github_open_issues
command: 'curl -s https://api.github.com/repos/ccostan/home-assistantconfig'
scan_interval: 20000
value_template: '{{ value_json.open_issues }}'
unit_of_measurement: 'count'
- sensor:
name: 'GitHub Stargazers'
unique_id: github_stargazers
command: 'curl -s https://api.github.com/repos/ccostan/home-assistantconfig'
scan_interval: 20000
value_template: '{{ value_json.stargazers_count }}'
unit_of_measurement: 'count'
sensor:
- platform: history_stats
name: Speech time
entity_id: media_player.livingroomCC
state: 'playing'
type: time
end: '{{ now() }}'
duration:
hours: 24
- platform: history_stats
name: TV time
entity_id: media_player.living_room_ultra
state: 'playing'
type: time
end: '{{ now() }}'
duration:
hours: 24
- platform: history_stats
name: Landscaping Light time
entity_id: group.landscaping
state: 'on'
type: time
end: '{{ now() }}'
duration:
hours: 24
- platform: history_stats
name: Tesla Charging time
entity_id: sensor.carlojuice_charging_status
state: 'charging'
type: time
end: '{{ now() }}'
duration:
days: 7
### Building some interesting stats for tweeting. ###
- platform: template
sensors:
sensor_count:
friendly_name: 'Number of Sensors'
value_template: >-
{{ states.sensor | list | count }}
unit_of_measurement: 'count'
icon_template: mdi:counter
automation_count:
friendly_name: 'Number of Automations'
value_template: >-
{{ states.automation | list | count }}
unit_of_measurement: 'count'
icon_template: mdi:robot
script_count:
friendly_name: 'Number of Scripts'
value_template: >-
{{ states.script | list | count }}
unit_of_measurement: 'count'
icon_template: mdi:script-text
binary_sensor_count:
friendly_name: 'Number of Binary Sensors'
value_template: >-
{{ states.binary_sensor | list | count }}
unit_of_measurement: 'count'
icon_template: mdi:binary-sensor
tracker_count:
friendly_name: 'Number of Devices'
value_template: >-
{{ states.device_tracker| list | count }}
unit_of_measurement: 'count'
icon_template: mdi:account-group
lights_count:
friendly_name: 'Number of Lights'
value_template: >
{{ states.light | list | count }}
unit_of_measurement: 'count'
icon_template: mdi:lightbulb
lights_on_count:
friendly_name: "Number of lights on"
value_template: >-
{% set lights = states.light | selectattr('state', 'eq', 'on') | list %}
{% set qty = lights | count %}
{% set p1 = 'lights are' if qty > 1 else 'light is' %}
{% if qty == 0 %}
No lights on.
{% else %}
{{ qty }} {{ p1 }} on.
{% endif %}
unit_of_measurement: 'count'
icon_template: mdi:binary-sensor
protect_count:
friendly_name: 'Number of Smoke Detectors'
value_template: >
{% if states('group.protects') == 'on' %}
{% for e in states.group.protects.attributes.entity_id if states(e) == 'on' %}
{% if loop.last %}
{{ loop.index }}
{% endif %}
{%- endfor -%}
{% else %}
0
{% endif %}
unit_of_measurement: 'count'
icon_template: mdi:smoke-detector
camera_count:
friendly_name: 'Number of online Cameras'
value_template: >
{{ states.camera | list | count }}
unit_of_measurement: 'count'
icon_template: mdi:camera
total_wifi_clients:
friendly_name: "Total WiFi Clients"
unique_id: total_wifi_clients
unit_of_measurement: "clients"
icon_template: mdi:wifi
value_template: >
{% set g = states('sensor.unifi_ap_garage_clients') | int(0) %}
{% set o = states('sensor.unifi_ap_office_clients') | int(0) %}
{% set s = states('sensor.unifi_ap_study_clients') | int(0) %}
{{ g + o + s }}