The query in Grafana:
the $__timeFilter is necessary to get min and max in this timerange:
SELECT
last_updated_ts AS “time”,
cast(state as float) as ‘Rauchmelder-Temp’
FROM home_ass.states
WHERE
$__timeFilter(FROM_UNIXTIME(cast(last_updated_ts as INT))) and metadata_id=‘3256’
The query Inspector make this query to the database:
SELECT
last_updated_ts AS “time”,
cast(state as float) as ‘Rauchmelder-Temp’
FROM home_ass.states
WHERE
FROM_UNIXTIME(cast(last_updated_ts as INT BETWEEN FROM_UNIXTIME(1709161200) AND FROM_UNIXTIME(1709247599))) and metadata_id=‘3256’
and give an error on the database
on this database it is necassary to use FROM_UNIXTIME and CAST INT to get the right query the field is TYPE “double” and holds the timestamp in this format:
“1708312321.499097”
The working query on the database:
SELECT
last_updated_ts AS “time”,
FROM_UNIXTIME(cast(last_updated_ts as INT)) AS “time2”,
cast(state as float) as ‘Rauchmelder-Temp’
FROM home_ass.states
WHERE
FROM_UNIXTIME(cast(last_updated_ts as INT)) BETWEEN FROM_UNIXTIME(1709074800) AND FROM_UNIXTIME(1709161199) and metadata_id=‘3256’;
- What Grafana version and what operating system are you using?
grafana-enterprise 9.1.0 as docker running on synology
The database is a mariadb version 10.3.32-10240 running on synology
Regards
Robert