Hi all!
I think i have found a bug. I wanted to monitor tables in my HA Database. So, first of all, ive added following manual configuration:
- platform: sql
db_url: mysql://homeassistant:[email protected]/homeassistant?charset=utf8mb4
queries:
- name: HomeAssistant DB Size
query: 'SELECT table_schema "database", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="homeassistant" GROUP BY table_schema;'
column: 'value'
unit_of_measurement: MB
- name: HomeAssistant States DB Size
query: 'SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "homeassistant" AND table_name = "states" ORDER BY (data_length + index_length) DESC;'
column: 'value'
unit_of_measurement: MB
- name: HomeAssistant State Attributes DB Size
query: 'SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "homeassistant" AND table_name = "state_attributes" ORDER BY (data_length + index_length) DESC;'
column: 'value'
unit_of_measurement: MB
- name: HomeAssistant Statistics Short Term DB Size
query: 'SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "homeassistant" AND table_name = "statistics_short_term" ORDER BY (data_length + index_length) DESC;'
column: 'value'
unit_of_measurement: MB
- name: HomeAssistant Statistics DB Size
query: 'SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "homeassistant" AND table_name = "statistics" ORDER BY (data_length + index_length) DESC;'
column: 'value'
unit_of_measurement: MB
- name: HomeAssistant Events DB Size
query: 'SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "homeassistant" AND table_name = "events" ORDER BY (data_length + index_length) DESC;'
column: 'value'
unit_of_measurement: MB
But after restart, HA adds only first query (HomeAssistant DB Size), and rest 5 is marked as “Newly found Device - SQL”.
So then, i removed from config (which i don’t like, since i feel better with YAML configuration than UI one), and tried to add SQL integration manually.
One time it works, but second time it claims that “invalid SQL address” And when i left SQL address empty, it says “Invalid SQL statement”.
What is wrong? Looks like bug for me.