Drop duplicated indices from schema
https://docs.percona.com/percona-toolkit/pt-duplicate-key-checker.html
```
% pt-duplicate-key-checker --databases fresh
ALTER TABLE `fresh`.`events` DROP INDEX `ix_events_event_type_id`;
ALTER TABLE `fresh`.`states` DROP INDEX `ix_states_metadata_id`;
ALTER TABLE `fresh`.`statistics` DROP INDEX `ix_statistics_metadata_id`;
ALTER TABLE `fresh`.`statistics_short_term` DROP INDEX `ix_statistics_short_term_metadata_id`;
```
* Switch history stats to report in seconds
Because hours were previously used, the data would always be off because
of the loss of resolution when the time being tracked was in a window
of more than 12s
* Apply suggestions from code review
* Update homeassistant/components/history_stats/sensor.py
* tweak
* Split context id migration into states and events tasks
Since events can finish much earlier than states we
would keep looking at the table because states as not
done. Make them seperate tasks
* add retry dec
* fix migration happening twice
* another case
* Fix flux_led set time test
If this test was run at the wrong time of the day
it would not have been long enough for the set time
to fire since it only happens at 2:40:30 in the morning
local time
* Revert "Fix flux_led set time test"
This reverts commit 3241912eff.
* Change time set to not be during DST switch
* Deduplicate event_types in the events table
* Deduplicate event_types in the events table
* more fixes
* adjust
* adjust
* fix product
* fix tests
* adjust
* migrate
* migrate
* migrate
* more test fixes
* more test fixes
* fix
* migration test
* adjust
* speed up
* fix index
* fix more tests
* handle db failure
* preload
* tweak
* adjust
* fix stale docs strings, remove dead code
* refactor
* fix slow tests
* coverage
* self join to resolve query performance
* fix typo
* no need for quiet
* no need to drop index already dropped
* remove index that will never be used
* drop index sooner as we no longer use it
* Revert "remove index that will never be used"
This reverts commit 461aad2c52.
* typo
* Make client tracker use common UniFi entity class
* Fix tests
* Fix mypy
* Remove legacy data
* Fix comment: skip else use return
* Minor change
* Remove missed stuff from previous rebase
* Import async_device_available_fn from entities.py rather than specifying it in device_tracker
* Avoid using asserts
* Keep explicit parenthesis for readability
* Allow loading entities on option changes
* Move coordinator to own file and add test cases
* Apply typing improvements from review
* Remove testcase for exception during setup
* Simplify unittest for failing serial connection
* Readd checks in serial connection test after review