Telegram add Chart

Hello
i have this working Telegram sending! all Fine!


But i have crated this Graph/Chart too and would like to add it too to my telegram Message!
Is something like that possible?

i do use the
node-red-contrib-telegrambot 8.9.6

have a nice day
vinc

Not possible. The chart is rendered client side (in a browser) everything else (including telegram) is server side (in node-red).

There are a bunch of if, but IF you are running on a linux device (like a Pi) AND you are storing the data so it can be retrieved:

You can instal gnuplot and create an ascii plot and save it as a file. Then send the image via telegram.

Here is a flow that creates a plot every two hours that you can try out (you will have to modify)

[{"id":"4e1a04ad.c2a3cc","type":"group","z":"4dd4bd87.9bb2cc","name":"","style":{"fill":"#ffdf7f","label":true},"nodes":["ca9804e4.a6ba6","75a25275.fa8784","43e46977.28a77","486e201a.97b178","83141676.3ddd88","64ef4651.4f425","73c2dddb.74bae4","9ffc5a47.a9efd8","f59b2621.a6e6d8","4c91b080.92b3d","601fd42d.8cef64","9d9c685e.f94008","8d0778e7.ecda","31f9a81f.1c14c"],"x":27,"y":7,"w":679,"h":514},{"id":"ca9804e4.a6ba6","type":"change","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"gnuplot last6hours.plot  > last6hours.jpg","rules":[{"t":"set","p":"payload","pt":"msg","to":"gnuplot last6hours.plot  > last6hours.jpg","tot":"str"},{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"columns","pt":"msg"},{"t":"delete","p":"rc","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":360,"wires":[["486e201a.97b178"]]},{"id":"75a25275.fa8784","type":"comment","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"Create the plot twice an hour","info":"","x":173,"y":48,"wires":[]},{"id":"43e46977.28a77","type":"file","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"","filename":"/home/pi/chart.csv","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":430,"y":320,"wires":[["ca9804e4.a6ba6"]]},{"id":"486e201a.97b178","type":"exec","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":390,"y":440,"wires":[["73c2dddb.74bae4"],["64ef4651.4f425"],["83141676.3ddd88"]]},{"id":"83141676.3ddd88","type":"debug","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":610,"y":480,"wires":[]},{"id":"64ef4651.4f425","type":"debug","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":610,"y":440,"wires":[]},{"id":"73c2dddb.74bae4","type":"debug","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":610,"y":400,"wires":[]},{"id":"9ffc5a47.a9efd8","type":"link in","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"GetGraph","links":["e0f488bc.64eff8"],"x":140,"y":100,"wires":[["601fd42d.8cef64"]],"l":true},{"id":"f59b2621.a6e6d8","type":"sqlite","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","mydb":"aa34218.e3a326","sqlquery":"msg.topic","sql":"","name":"plants.db","x":400,"y":140,"wires":[["31f9a81f.1c14c"]]},{"id":"4c91b080.92b3d","type":"inject","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"H/L twice/Hour","props":[{"p":"payload"}],"repeat":"1800","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":170,"y":140,"wires":[["601fd42d.8cef64"]]},{"id":"601fd42d.8cef64","type":"template","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"Query v1","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT \n    strftime('%H', isodate)  AS hourly,\n    MAX(temperature_F) AS tempHigh,\n    MIN(temperature_F) AS tempLow,\n    MAX(humidity)      AS humiHigh,\n    MIN(humidity)      AS humiLow\nFROM RS_PLANTS\nWHERE\n    isodate >= datetime('now','-6 hours')\nGROUP BY hourly","output":"str","x":400,"y":100,"wires":[["f59b2621.a6e6d8"]]},{"id":"9d9c685e.f94008","type":"csv","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"","sep":",","hdrin":"","hdrout":"all","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":390,"y":280,"wires":[["43e46977.28a77"]]},{"id":"8d0778e7.ecda","type":"change","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":240,"wires":[["9d9c685e.f94008"]]},{"id":"31f9a81f.1c14c","type":"function","z":"4dd4bd87.9bb2cc","g":"4e1a04ad.c2a3cc","name":"","func":"//Initailize array of objects.\nlet l = msg.payload.length \nlet h = ''\n\nfor (i = 0; i < l; i++) {\n    let c = msg.payload[i].hourly\n\n// add AM/PM Noon or Midnight\n    switch (msg.payload[i].hourly){\n        case '00':\n            msg.payload[i].hourly = 'Midnight'\n            break;\n        case '01':\n        case '02':\n        case '03':\n        case '04':\n        case '05':\n        case '06':\n        case '07':\n        case '08':\n        case '09':\n        case '10':\n        case '11':\n            h = parseInt(msg.payload[i].hourly)\n            msg.payload[i].hourly = h.toString() + 'AM'\n            break;\n        case '12':\n            msg.payload[i].hourly = 'Noon'\n            break;\n        case '13':\n        case '14':\n        case '15':\n        case '16':\n        case '17':\n        case '18':\n        case '19':\n        case '20':\n        case '21':\n        case '22':\n        case '23':\n            h = parseInt(msg.payload[i].hourly)\n            h = h-12\n            msg.payload[i].hourly = h.toString() + 'PM'\n            break;\n        default: \n            node.warn(\"OOPS, the hour is invalid!!\"+c);\n    }\n \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":200,"wires":[["8d0778e7.ecda"]]},{"id":"aa34218.e3a326","type":"sqlitedb","db":"/home/pi/databases/plants.db","mode":"RWC"}]

Merci @zenofmud
yes it is a Pi and local stored in influxDB!
and i will have to install the sqlnode too.
how did you add this colored background?

have a nice day
vinc

You should keep up with the blog and relase notes :wink: Version 1.1 released : Node-RED

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.