Skip to content

Solution HAstats

Arve edited this page Sep 1, 2023 · 19 revisions

Why ??

  • I'm actually rather fond of numbers and looking at development through history of a journey from an number perspective
  • So I googled a bit, and found something I found useful, and created a 'solution' for hastats. And then split it into a few sub-solutions just for structure.

Credits/inspiration:


Requirements/install tips:

Click to unfold list of booring requirements, tips etc

Functionality required (other than what is builtin in my version of HA):

  • HACS: Lovelace-Mushroom card-package
  • HACS: browser mod - for popup-functionality
  • HACS: Start_time
  • HACS: custom:tabbed-card
  • HACS: custom:auto-entities
  • HACS: custom:history-explorer-card
  • Packages-folder, to copy entire yaml-config in one file
  • YAML-dashboard - easy share config, can use !include and re-use cards
    • as an option you can copy dashboard-config to UI-dashboard/card - but not if !include is used,,

template-editor test-code:

(because HA-team is constantly adding new functionality/domains,, it is useful to get to check/verify that we actually got all configured with sensors,,,)

_____________________________________________________________________
Stats of how many entities pr domain are in my HA-instance, by ArveVM


# check ONE specific domain:
   Automations =  {{ states.automation | count}}

# check ALL domain:
  {%- for domain in states | map(attribute='domain') | unique %}
  {{ domain ~ 's : ' ~ states[domain] | count }}
  {%- endfor %}
  {{ '  Total: ' ~ states | count }}    

# check ALL domain (sorted, but with lines between :( ):
  {% for domain in states | map(attribute='domain') | unique | sort %}
  {{ domain ~ 's : ' ~ states[domain] | count }}
  {% endfor %}
  {{ '  Total: ' ~ states | count }}
 

Table of contents:

  • HAstats-main - Gather all sub-solutions in one card. Tabbed card with sub-solutions on each tab. One tab with reference to this GitHub-repo for documentation-purposes
  • HAstats-Integrations - Counter of integrations loaded. Graphed long term history. PopUp with list of all current integrations, with load-times at startup/reload|
  • HAstats-Enteties By Domain - Counter of entities pr domain. Grouped and presented 5 most "important". Graphed long term history. PopUp with list of all current integrations, with load-times at startup/reload.
  • HAstats Yaml line count - Count yaml-lines for config and dashboard.
  • HAstats-DB - Track size of Recorder DataBase.


How it works (for me):

  • Created sensors to count different KPI's of my HA-installations "growth". Added sensors as long term statistics - so we can see (and graph) long term trends
  • Adding sub-solutions for each type of stats, so that it is easier to grasp concept of each "kpi-group"
    • Adding card for each sub-solution
  • Adding tabbed card to combine all sub-solutions in one card - with link to documentation.
    • and a chip to easily place link on dashboard.


HAstats-main

Card/chip preview Card Config Use case(s)
insert card-picture insert card-link link to yaml-config list use-cases
- Link to Solution documentation
image HAstats-card n/a - Overview of all cards in a tabbed-card
- Link to Solution documentation

HAstats-Integrations

  • Sub-solution, own card and config-yaml
  • Start-time integration gives sensor with attributes of all loaded integration and their "startup-time".
  • Using history-explorer-graph with long-term statistics enabled, so the configured sensor with long term statistics enabled are visible.
Card/chip preview Card Config Use case(s)
image HAstats_integrations_card HAstats_integrations.yaml - view development in number of integrations
- click to list all integrations
image Popup "Integrations by startup-time" - list all integrations
- see startup-times (dependencies will heavily skew this!!)

HAstats-Entities By Domain (ebd)

  • Sub-solution, own card and config-yaml
  • Manually created sensors to count entities pr respective domains.
  • Using history-explorer-graph with long-term statistics enabled, so the configured sensor with long term statistics enabled are visible.
Card/chip preview Card Config Use case(s)
image HAstats_ebd_card hastats_ebd.yaml - Overview of count in entities
- click for details
image Popup "Total"
image Popup "Sensors"
image Popup "Automations"
etc on scripts and lights

NB; sensor.hastats_ebd_total_checksum - counts sum of grouped-sensors in sensors against total number of sensors and if not 0 then you are missing sensor-count for one "entity-type" - look in troubleshooting for code


HAstats-YAML line count

  • Sub-solution, own card and config-yaml
  • Organized yaml-config in separate folder, and the same with Dashboard
  • Manually created sensors to count yaml-lines pr respective folders.
  • Using history-explorer-graph with long-term statistics enabled, so the configured sensor with long term statistics enabled are visible.
  • Please note that YAML-count includes empty lines and comments,,, but I'll further invest in using wiki and not config/dashboard-yaml for comments,, so it will get realistic sometime in the future.
Card/chip preview Card Config Use case(s)
image HAstats_yaml_lines_card hastats_yaml_lines.yaml - see development in config/dashboard #lines

HAstats-DB

  • Sub-solution, own card and config-yaml
  • Created sensor to monitor db-size
  • Using history-explorer-graph with long-term statistics enabled, so the configured sensor with long term statistics enabled are visible.
Card/chip preview Card Config Use case(s)
image HAstats_db_card hastats_db.yaml view development in:
- DB-size
- states
- longterm-statistics
- short-term-statistics

Improvements planned/project queue:

  • might want to move the system_monitor.yaml sensors here (as there is no config of the integration)
  • change 'float(default=0)' to 'float(0)' - no reason to keep the default ?
  • change to monthly graphs when I get several months of data (or just keep floating line?? )

Solution history

  • Aug 2023: Improved card, better overview, improved solution documentation
  • Sept 2022: Initial setup
Clone this wiki locally