J. Nick Koston
522a9bb6b1
Exclude supported features and attribution from being recorded in the database ( #69165 )
2022-04-03 13:51:42 +02:00
J. Nick Koston
f5a13fc51b
Add ability to exclude attributes from being recorded by entity domain ( #68824 )
2022-03-29 20:13:08 -07:00
J. Nick Koston
d7634d1cb1
Additional strict typing for additional recorder internals ( #68689 )
...
* Strict typing for additional recorder internals
* revert
* fix refactoring error
2022-03-29 09:45:25 +02:00
Marc Mueller
53245c6523
Update pylint to 2.13.0 ( #68656 )
2022-03-25 15:14:48 -07:00
J. Nick Koston
c5c34bc0d7
Typing and code quality for recorder history ( #68647 )
2022-03-24 17:58:38 -07:00
J. Nick Koston
3150915cb7
Convert unindexed domain queries to entity_id queries ( #68404 )
2022-03-20 01:28:17 -10:00
J. Nick Koston
0c0df07c52
Avoid hashing attributes when they are already in the cache ( #68395 )
2022-03-19 23:33:37 -07:00
J. Nick Koston
9864090e0b
Cache parsing attr in LazyState ( #68232 )
2022-03-18 07:44:37 -07:00
J. Nick Koston
9215702388
Separate attrs into another table (reduces database size) ( #68224 )
2022-03-18 00:23:13 -10:00
J. Nick Koston
b18096fc54
Remove unused columns from states/events tables ( #68078 )
2022-03-13 23:44:55 -07:00
Marc Mueller
cb736eaeaf
Add type ignore error codes [recorder] ( #66780 )
2022-02-18 10:37:38 +01:00
Erik Montnemery
bceeaec2f8
Remove duplicated statistics rows ( #61146 )
...
* Remove duplicated statistics
* Fix misleading docstring
* Pylint knows best
* Correct test
* Oops
* Prevent insertion of duplicated statistics
* Tweak
* pylint
* Add models_schema_23.py
* Tweak
2021-12-13 14:15:36 +01:00
Erik Montnemery
f594bc353b
Add support for external statistics ( #56607 )
...
* Support external statistics
* Update tests
* Lint
* Adjust code after rebase
* Separate external statistic_id with :, add name to metadata
* Adjust tests
* Simplify get_metadata_with_session
* Address review comments
* Allow updating external statistics
* Validate input
* Adjust tests after rebase
* Pylint
* Adjust tests
* Improve test coverage
2021-10-26 10:26:50 +02:00
Erik Montnemery
a966714032
Minor cleanup of recorder statistics code ( #55339 )
2021-09-29 11:42:39 -07:00
Erik Montnemery
40ecf22bac
Remove automatic splitting of net meters from statistics ( #56772 )
2021-09-29 17:20:17 +02:00
Erik Montnemery
92253f5192
Minor refactoring of periodic statistics ( #56492 )
2021-09-22 13:31:33 -07:00
Marcin Ciupak
b9ffd74db5
Fix recorder Oracle DB models ( #55564 )
...
* Fix recorder models for Oracle DB
* Fix StatisticsRuns
* Update migration for Oracle Identity columns.
* Update migration logic
Migration to schema version 22 done only for engine dialect oracle
* Add missing table check in schema 22 migration
2021-09-21 00:38:42 +02:00
Erik Montnemery
8c5efafdd8
Add 5-minute statistics for sensors ( #56006 )
...
* Add 5-minute statistics for sensors
* Address pylint issues
* Black
* Apply suggestion from code review
* Apply suggestions from code review
* Improve tests
2021-09-16 10:57:15 +02:00
Erik Montnemery
d2a9f7904a
Include end time of statistics data points in API response ( #56063 )
...
* Include end time of statistics data points in API response
* Correct typing
* Update tests
2021-09-13 10:02:24 +02:00
Erik Montnemery
2a8121bdcd
Really change character set of statistics_meta table to utf8 ( #56029 )
2021-09-09 22:55:51 +02:00
Erik Montnemery
a47532c69b
Change character set of statistics_meta table to utf8 ( #56011 )
2021-09-09 17:24:20 +02:00
Erik Montnemery
80fd330479
Add sum_decrease and sum_increase statistics ( #55850 )
2021-09-08 23:35:53 -07:00
Erik Montnemery
7e70252de5
Handle statistics for sensor with changing state class ( #55316 )
2021-08-27 16:18:49 +02:00
Erik Montnemery
6d4a47a53d
Fix double precision float for postgresql ( #55249 )
2021-08-26 10:06:53 +02:00
Erik Montnemery
8877f37da0
Fix statistics for sensors setting last_reset ( #55136 )
...
* Re-add state_class total to sensor
* Make energy cost sensor enforce state_class total_increasing
* Drop state_class total
* Only report energy sensor issues once
2021-08-24 17:02:34 +02:00
Erik Montnemery
0624859bf4
Set statistics columns to double precision ( #55053 )
2021-08-24 11:18:59 +02:00
Erik Montnemery
32e297f4a0
Compile missing statistics ( #54690 )
2021-08-19 22:10:45 -07:00
Erik Montnemery
e1926caeb9
Remove STATE_CLASS_TOTAL and last_reset from sensor ( #54755 )
...
* Remove STATE_CLASS_TOTAL
* Update mill sensor
* Update tests
* Kill last_reset
* Return ATTR_LAST_RESET to utility_meter
* Update energy cost sensor
* Restore last_reset for backwards compatibility
* Re-add and update deprecation warning
* Update tests
* Fix utility_meter
* Update EnergyCostSensor
* Tweak
* Fix rebase mistake
* Fix test
2021-08-18 10:03:27 +02:00
Paulus Schoutsen
557cc792e9
Fix SQLAlchemy test warnings ( #54116 )
2021-08-08 20:33:47 -07:00
Franck Nijhof
c875ff8648
Store JSON in database in compact format ( #53364 )
...
* Store JSON in database in compact format
* Fix logbook
2021-07-22 12:05:59 -10:00
Erik Montnemery
19d3aa71ad
Enable basic type checking for recorder ( #52440 )
...
* Enable basic type checking for recorder
* Tweak
2021-07-13 21:21:45 +02:00
Erik Montnemery
ed25e6fada
Correct recorder table arguments ( #52436 )
2021-07-02 16:28:16 +02:00
Erik Montnemery
24ae05b734
Drop statistic_id and source columns from statistics table ( #52417 )
...
* Drop statistic_id and source columns from statistics table
* Remove useless double drop of statistics table
* Update homeassistant/components/recorder/models.py
Co-authored-by: Franck Nijhof <git@frenck.dev>
* black
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-07-02 13:17:00 +02:00
Erik Montnemery
0ab999738b
Add statistics meta data table ( #52331 )
...
* Add statistics meta data table
* Tweak meta data generation
2021-06-30 13:32:17 +02:00
Raman Gupta
58e37435b3
Make more max lengths constants and add additional MaxLengthExceeded checks ( #50337 )
...
* Add more MaxLengthExceeded checks
* remove some validations to reduce performance impact
* check length of generated entity ID
* dont check entity ID twice and use single context id length constant
* fix test
* add missing test
2021-05-25 19:58:01 +02:00
Marcin Ciupak
caad125b44
Add support for Oracle DB in recorder ( #50090 )
2021-05-22 21:10:27 -05:00
Erik Montnemery
e16a8063a5
Compile statistics for energy sensors ( #50829 )
...
* Compile statistics for energy sensors
* Update tests
* Rename abs_value to state
* Tweak
* Recreate statistics table
* Pylint
* Try to fix test
* Fix statistics for multiple energy sensors
* Fix energy statistics when last_reset is not set
2021-05-20 13:05:15 +02:00
Erik Montnemery
89dd3292ba
Initial draft of statistics ( #49852 )
2021-05-16 10:23:37 -07:00
Erik Montnemery
973f59e423
Refactor history component ( #50287 )
...
* Refactor history component
* Update tests
* Address review comments
* Correct deprecated functions
2021-05-11 09:21:57 +02:00
Raman Gupta
3ca69f5568
Raise an exception when event_type exceeds the max length ( #48115 )
...
* raise an exception when event_type exceeds the max length that the recorder supports
* add test
* use max length constant in recorder
* update config entry reloaded service name
* remove exception string function because it's not needed
* increase limit to 64 and revert event name change
* fix test
* assert exception args
* fix test
* add comment about migration
2021-04-08 20:46:28 +02:00
Laszlo Magyar
c7e4857d2c
Let recorder deal with event names longer than 32 chars ( #47748 )
2021-04-08 07:08:49 -10:00
Stefan Agner
815db999da
Use microsecond precision for datetime values on MariaDB/MySQL ( #48749 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-04-07 09:13:55 +02:00
J. Nick Koston
61a2460c87
Improve error reporting in recorder purge test ( #47929 )
2021-03-14 19:46:21 -07:00
Marc Mueller
10848b9bdf
Recorder improvements ( #47739 )
2021-03-11 07:52:07 -10:00
CurrentThread
7c8851264f
Use LONGTEXT column instead of TEXT for MySQL/MariaDB and migrate existing databases ( #47026 )
2021-03-10 08:12:58 -10:00
J. Nick Koston
a060acc2b1
Fix recorder with MSSQL ( #46678 )
...
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2021-03-09 11:16:19 -10:00
J. Nick Koston
12af87bc6e
Add index to old_state_id column for postgres and older databases ( #44757 )
...
* Add index to old_state_id column for older databases
The schema was updated in #43610 but the index was not
added on migration.
* Handle postgresql missing ondelete
* create index first
2021-01-04 10:51:44 +01:00
J. Nick Koston
1162d9a752
Create tables with a charset that can hold all expected data under mysql ( #43732 )
...
By default these tables are created with utf8 which can only hold 3 bytes. This
meant that all emjoi would trigger a MySQLdb._exceptions.OperationalError because
they are 4 bytes.
This will only fix the issue for users who recreate their tables.
2020-11-28 23:54:05 +01:00
moinmoin-sh
337b8d279e
Ensure MariaDB/MySQL can be purged and handle states being deleted out from under the recorder ( #43610 )
...
* MariaDB doesn't purge #42402
This addresses home-assistant#42402
Relationships within table "states" and between tables "states" and "events " home-assistant#40467 prevent the purge from working correctly. The database increases w/o any purge.
This proposal sets related indices to NULL and permits deleting of rows.
Further explanations can be found here home-assistant#42402
This proposal also allows to purge the tables "events" and "states" in any order.
* Update models.py
Corrected for Black style requirements
* Update homeassistant/components/recorder/models.py
Co-authored-by: J. Nick Koston <nick@koston.org>
* Add the options to foreign key constraints
* purge old states when database gets deleted out from under us
* pylint
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-11-28 08:42:29 -10:00
J. Nick Koston
4798f37c6e
Convert States to dicts via as_dict only once ( #41208 )
...
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-10-05 09:18:57 -05:00