Last active
February 22, 2022 15:24
-
-
Save theundefined/f8094aa0a9c4fa5914553320cc984d7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wyszukanie dat gdzie są dziury: | |
select * from statistics where metadata_id = 108; | |
# aktualizacja wartości na ostatnią znaną przy dacie gdzie była dziura | |
update statistics set state=4489.043,sum=1249.331 where state=0 and date(created)='2022-02-02' and metadata_id=108; | |
# aktualizacja sumy | |
update statistics_short_term set sum=state-3239.712 where metadata_id=108 and state > 0; | |
update statistics set sum=state-3239.712 where metadata_id=108 and state > 0; | |
# wyswietlenie tabel | |
root@hs:~/ha.config# sqlite3 home-assistant_v2.db | |
SQLite version 3.22.0 2018-01-22 18:45:57 | |
Enter ".help" for usage hints. | |
sqlite> .tables | |
events states statistics_runs | |
recorder_runs statistics statistics_short_term | |
schema_changes statistics_meta | |
sqlite> .schema statistics_meta | |
CREATE TABLE statistics_meta ( | |
id INTEGER NOT NULL, | |
statistic_id VARCHAR(255), | |
source VARCHAR(32), | |
unit_of_measurement VARCHAR(255), | |
has_mean BOOLEAN, | |
has_sum BOOLEAN, name VARCHAR(255), | |
PRIMARY KEY (id) | |
); | |
CREATE INDEX ix_statistics_meta_statistic_id ON statistics_meta (statistic_id); | |
# wyłuskanie id: | |
sqlite> select * from statistics_meta where statistic_id like '%pv_gen%'; | |
33|sensor.hourly_pv_gen_meter|recorder|kWh|0|1| | |
34|sensor.daily_pv_gen_meter|recorder|kWh|0|1| | |
35|sensor.monthly_pv_gen_meter|recorder|kWh|0|1| | |
36|sensor.yearly_pv_gen_meter|recorder|kWh|0|1| | |
108|sensor.pv_gen_meter|recorder|kWh|0|1| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment