hello,
well never used a SQL db before… so bare with me…
here is my problem…
i’ll using the MariaDB now … sucks…
needed some time to find out that you have to use “” for the URL … all little strange to me…
- platform: sql
db_url: "mysql://homeassistant:XXX@core-mariadb/homeassistant?charset=utf8mb4"
queries:
- name: Bresser51 DB Rain 1H
query: >-
SELECT * FROM states
WHERE entity_id = 'sensor.bresser51_rain'
AND last_updated < CURRENT_TIMESTAMP - INTERVAL '1 hour'
ORDER BY last_updated DESC
LIMIT 1;
column: state
unit_of_measurement: mm
- name: Bresser51 DB Rain 24H
query: >-
SELECT * FROM states
WHERE entity_id = 'sensor.bresser51_rain'
AND last_updated < CURRENT_TIMESTAMP - INTERVAL '24 hour'
ORDER BY last_updated DESC
LIMIT 1;
column: state
unit_of_measurement: mm
- name: Bresser51 DB Rain 168H
query: >-
SELECT * FROM states
WHERE entity_id = 'sensor.bresser51_rain'
AND last_updated < CURRENT_TIMESTAMP - INTERVAL '168 hour'
ORDER BY last_updated DESC
LIMIT 1;
column: state
unit_of_measurement: mm
can’t get it to work… did not found any example for MariaDB … only how to find out the size of the db
also use the !secret for URL & Pass… this is just for testing…
Never mind that the Url to db must be in " " … nothing in documentation about it …
maybe use a other SQL DB ? …
don’t know how the query works with MariaDB… if someone could help me would be awesome …
many thx
M.