I found similar topic but it concern influxdb database.
I want to draw daily water usage, which I have in MySQL table named “water”. Into this table is two columns: Date and Amount.
MySQL is installed in HA, but it isn’t current recorder.
I try to modify data generator. Original was:
data_generator: |
console.log(start);
var params = new URLSearchParams({
pretty: true,
db: "sensors",
q: "SELECT mean(\"value\") FROM \"solar\" WHERE \"entity_id\" = 'month' AND time >= '" + start.toISOString() + "' AND time <= '" + end.toISOString() + "' GROUP BY time(1d) fill(none)"
});
var myInit = { method: 'GET',
headers: {
'Accept': 'application/json',
},
mode: 'cors',
cache: 'default'
};
const request = async () => {
var result = [];
const response = await fetch('http://127.0.0.1:8086/query?' + params, myInit)
const json = await response.json();
if (json["results"] && json["results"][0] && json["results"][0]["series"] && json["results"][0]["series"][0] && json["results"][0]["series"][0]["values"]) {
for(var val of json["results"][0]["series"][0]["values"]) {
result.push([new Date(val[0]), val[1]]);
}
} else {
console.log("error: " + json)
}
return result;
}
return request();
Actually I modified all data in card but I don’t know what instert in line
const response = await fetch(‘http://influxdb.lan:8086/query?’ + params, myInit)
where should be mysql server.