Setup & Configuration

General Setup
There are many ways to install Home Assistant. Here is some detail on my instance:
- I am using Home Assistant Container but this page explains all the options
- My instance is running in Docker on a QNAP TS-253A
- More info from my blog about my setup and network environment
Reference Configurations:
- https://github.com/basnijholt/home-assistant-config
- https://github.com/geekofweek/homeassistant
- https://github.com/CCOSTAN/Home-AssistantConfig
- https://github.com/arsaboo/homeassistant-config
Useful Information:
- Understanding the configuration.yaml file
- Split Configuration - various options to structure the configuration files to keep the data bettter organized
- See also Packages
- Create a secrets file to keep personal data out of the configuration (use case: makes it easier to share your configuration online)
Database Configuration
- How Home Assistant stores data
- Use the Recorder Integration to connect Home Assistant to a database server
- Things to consider:
- purge_days_keep attribute - how long to keep data before it is purged. An auto purge is run every night unless disabled.
- good info even if not using SD card…
- Useful SQL Queries (Postgres):
-
Count of records added per hour over last 3 days:
SELECT date_trunc('hour', last_updated), count(1) FROM states WHERE last_updated > now() - interval '3 day' GROUP BY 1
-
Check the oldest records in the
events
&states
tables to confirm HA is purging the DB as per thepurge_keep_days
value:SELECT event_id, created FROM events ORDER BY created LIMIT 10;
-
To Find the size of HA’s tables:
SELECT nspname || '.' || relname AS "relation", pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') AND C.relkind <> 'i' AND nspname !~ '^pg_toast' ORDER BY pg_total_relation_size(C.oid) DESC LIMIT 5;
-
To Find the size of the indexes of HA’s tables:
SELECT relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch, pg_size_pretty(pg_relation_size(indexrelname::regclass)) as size FROM pg_stat_all_indexes WHERE schemaname = 'public' AND indexrelname NOT LIKE 'pg_toast_%' AND idx_scan = 0 AND idx_tup_read = 0 AND idx_tup_fetch = 0 ORDER BY pg_relation_size(indexrelname::regclass) DESC;
-