2017-02-26 22:38:06 +00:00
|
|
|
"""Recorder constants."""
|
|
|
|
|
2022-03-20 06:33:37 +00:00
|
|
|
from functools import partial
|
|
|
|
import json
|
|
|
|
from typing import Final
|
|
|
|
|
2022-04-16 21:09:08 +00:00
|
|
|
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_RESTORED, ATTR_SUPPORTED_FEATURES
|
2022-03-20 06:33:37 +00:00
|
|
|
from homeassistant.helpers.json import JSONEncoder
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
DATA_INSTANCE = "recorder_instance"
|
2020-07-18 05:07:37 +00:00
|
|
|
SQLITE_URL_PREFIX = "sqlite://"
|
2020-08-05 12:58:19 +00:00
|
|
|
DOMAIN = "recorder"
|
2020-09-02 08:12:56 +00:00
|
|
|
|
|
|
|
CONF_DB_INTEGRITY_CHECK = "db_integrity_check"
|
2021-03-09 21:16:19 +00:00
|
|
|
|
2022-04-14 21:45:07 +00:00
|
|
|
MAX_QUEUE_BACKLOG = 40000
|
2021-11-04 15:46:45 +00:00
|
|
|
|
2021-03-09 21:16:19 +00:00
|
|
|
# The maximum number of rows (events) we purge in one delete statement
|
2021-07-12 20:03:13 +00:00
|
|
|
|
|
|
|
# sqlite3 has a limit of 999 until version 3.32.0
|
|
|
|
# in https://github.com/sqlite/sqlite/commit/efdba1a8b3c6c967e7fae9c1989c40d420ce64cc
|
|
|
|
# We can increase this back to 1000 once most
|
|
|
|
# have upgraded their sqlite version
|
|
|
|
MAX_ROWS_TO_PURGE = 998
|
2022-03-18 09:09:01 +00:00
|
|
|
|
|
|
|
DB_WORKER_PREFIX = "DbWorker"
|
2022-03-20 06:33:37 +00:00
|
|
|
|
|
|
|
JSON_DUMP: Final = partial(json.dumps, cls=JSONEncoder, separators=(",", ":"))
|
2022-04-03 11:51:42 +00:00
|
|
|
|
2022-04-16 21:09:08 +00:00
|
|
|
ALL_DOMAIN_EXCLUDE_ATTRS = {ATTR_ATTRIBUTION, ATTR_RESTORED, ATTR_SUPPORTED_FEATURES}
|