Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
smart-home:home-assistant [2025/05/03 04:09] – created admin | smart-home:home-assistant [2025/05/03 05:04] (current) – [HA mysql] admin | ||
---|---|---|---|
Line 22: | Line 22: | ||
10A2ABxxxxxx - without double point | 10A2ABxxxxxx - without double point | ||
</ | </ | ||
+ | |||
+ | ==== HA CCTV frigate / scrypted | ||
+ | https:// | ||
+ | https:// | ||
+ | https:// | ||
+ | |||
+ | ===== HA. configue ===== | ||
+ | | ||
+ | icons https:// | ||
+ | ==== HA. Floor plan beauty | ||
+ | https:// | ||
+ | ==== HA articles ==== | ||
+ | https:// | ||
+ | |||
+ | ===== HA mysql ===== | ||
+ | ++++ Get stats of mysql - where data located| | ||
+ | <code SQL> | ||
+ | -- get count of state entity and count of history data | ||
+ | SELECT | ||
+ | states_meta.entity_id, | ||
+ | COUNT(*), | ||
+ | -- states.state, | ||
+ | from_unixtime(MIN(IF(states.last_changed_ts IS NULL, | ||
+ | states.last_updated_ts, | ||
+ | states.last_changed_ts))) AS first_changed_ts, | ||
+ | from_unixtime(Max(IF(states.last_changed_ts IS NULL, | ||
+ | states.last_updated_ts, | ||
+ | states.last_changed_ts))) AS last_changed_ts | ||
+ | FROM | ||
+ | states | ||
+ | LEFT JOIN | ||
+ | states_meta ON (states.metadata_id = states_meta.metadata_id) | ||
+ | GROUP BY states_meta.entity_id | ||
+ | ORDER BY 2 DESC | ||
+ | LIMIT 10; | ||
+ | | ||
+ | -- size of all tables | ||
+ | SELECT table_schema as `DB`, table_name AS `Table`, | ||
+ | ROUND(((data_length + index_length) / 1024 / 1024), 2) `Size (MB)` | ||
+ | FROM information_schema.TABLES | ||
+ | ORDER BY (data_length + index_length) DESC | ||
+ | limit 10; | ||
+ | |||
+ | -- optimize | ||
+ | OPTIMIZE TABLE homeassistant.states; | ||
+ | </ | ||
+ | ++++ | ||
+ | |||
+ | ===== HA - template ===== | ||
+ | <code BASH> | ||
+ | # home assistant - executing in day 24h | ||
+ | 01h 24 | ||
+ | 10m 144 | ||
+ | 05m 288 | ||
+ | 01m 1440 | ||
+ | 05s 17280 | ||
+ | 01s 86400 | ||
+ | |||
+ | {% set result = namespace(sensors=[]) %} | ||
+ | {% set exclude = [] %} | ||
+ | {% set hours = 1 %} | ||
+ | {% for state in states.sensor | rejectattr(' | ||
+ | {{state}} | ||
+ | {% if ' | ||
+ | {% set result.sensors = result.sensors + [state.name | regex_replace(find=' | ||
+ | {% endif %} | ||
+ | {% endfor %} | ||
+ | {{ result.sensors | join(', | ||
+ | |||
+ | |||
+ | </ | ||
+ |