Files
Home-AssistantConfig/config/packages/stats.yaml

157 lines
4.7 KiB
YAML
Executable File

######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Stats - Historical metrics and AI notifications.
# Build historical stats for AI/alerting.
# -------------------------------------------------------------------
# Contact: @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. ###
template:
- sensor:
- name: "Number of Sensors"
unique_id: stats_number_of_sensors
unit_of_measurement: "count"
icon: mdi:counter
state: >-
{{ states.sensor | list | count }}
- name: "Number of Automations"
unique_id: stats_number_of_automations
unit_of_measurement: "count"
icon: mdi:robot
state: >-
{{ states.automation | list | count }}
- name: "Number of Scripts"
unique_id: stats_number_of_scripts
unit_of_measurement: "count"
icon: mdi:script-text
state: >-
{{ states.script | list | count }}
- name: "Number of Binary Sensors"
unique_id: stats_number_of_binary_sensors
unit_of_measurement: "count"
icon: mdi:binary-sensor
state: >-
{{ states.binary_sensor | list | count }}
- name: "Number of Devices"
unique_id: stats_number_of_devices
unit_of_measurement: "count"
icon: mdi:account-group
state: >-
{{ states.device_tracker | list | count }}
- name: "Number of Lights"
unique_id: stats_number_of_lights
unit_of_measurement: "count"
icon: mdi:lightbulb
state: >
{{ states.light | list | count }}
- name: "Number of lights on"
unique_id: stats_number_of_lights_on
unit_of_measurement: "count"
icon: mdi:binary-sensor
state: >-
{{ states.light | selectattr('state', 'eq', 'on') | list | count }}
- name: "Number of Smoke Detectors"
unit_of_measurement: "count"
icon: mdi:smoke-detector
state: >
{% 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 %}
- name: "Number of online Cameras"
unique_id: stats_number_of_online_cameras
unit_of_measurement: "count"
icon: mdi:camera
state: >
{{ states.camera | list | count }}
- name: "Total WiFi Clients"
unique_id: total_wifi_clients
unit_of_measurement: "clients"
icon: mdi:wifi
state: >
{% 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 }}