CONF_PURGE_DAYS so it can be changed easier later.
Use 'recorder' domain instead of 'history' domain.
Pass purge_days config directly into Recorder object instead of passing
the config object around.
Issue https://github.com/balloob/home-assistant/issues/1337
When purge_days is set under the history component, recorder.py will
delete all events and states that are older than purge_days days ago.
Currently, this is only done once at start up. A vacuum command is
also run to free up the disk space sqlite would still use after deleting
records.
Two tests were invariably grinding my system to a halt as it was
applying migrations to an empty sqlite database. This patch reduces
the time of a pytest run from 50 to about 16 seconds on my desktop.
The difference is even more noticable on a slower laptop drive, but
is probably insignificant for all you fancy SSD users.
Some domains, like thermostat, need all state records, not just state
change ones, to provide accurate graphs. This introduces a new db
migration which adds a 'domain' column to all states so that is a fast
query.
Indexes were added to help with query performance.
This includes a data migration which post-date populates domain. On
large HA dbs this might take real time, as it has to touch every state
row. 100 MB db (91k states) updated in a couple of seconds on my
reasonably fast server. Be forewarned.
This is part of bug #881