I have running a ESP8266 on my QNAP and it is sending via MQTT temperature and humidity from DTH11 and its working great so far. I can also view the results in a line chart:
But I have no idea how to get the data from QHistoricData to feed the chart, I tried so many tutorials and forums but no luck so far.
I got the data with the example code and feed that into the QHistoric Data and then I want to draw that data in the line chart.
Code: Select all
var start_date = new Date();
start_date.setHours(start_date.getHours() - 2);
var msg = {
payload: {
start_date: start_date,
end_date: new Date()
}
};
return msg; // I added this line to return msg
Code: Select all
{
"payload": {
"start_date": "2019-02-06T15:13:30.648Z",
"end_date": "2019-02-06T17:13:30.654Z"
},
"_msgid": "fd9459b4.026ba8"
}
I show here only the first and last line:
Code: Select all
{
"payload": {
"result": [
{
"totalCount": 282,
"data": [
{
"count": 48,
"vmin": 19,
"sum": 957,
"vmax": 21,
"_id": "2019-02-05T17:13:30",
"vavg": 19.9375
}, ... and so on
{
"count": 48,
"vmin": 18,
"sum": 958,
"vmax": 21,
"_id": "2019-02-06T16:58:30",
"vavg": 19.958333333333332
}
]
}
]
},
"_msgid": "8ba78cc0.74587"
}
2 Question: This data i want to put into the line chart of node-red but there is no way I get it to work I don't know how I need to prepare the data in order to succeed:
I added x an y on the payload but no success
I tried feeding it this way as it comes out from QHistoryBlock
I tried to transform it to an array and feed it but no success,
Can someone please help me with those issues?
I should I rather send this date to home assistant?