Influxdb query problem

Is it possible to include a variable in the SELECT phrase retriving data from Influxdb?

Eg: SELECT xxx[varA] FROM yyy

If yes, what is the correct syntax?

Can you provide more info please ?

eg Are you talking about the node-red-contrib-influxdb node ?

If so what version of database is setup in the config node eg 1.x or 1.8 flux or 2.0

Are you asking about what you should put in the query, or how to build the query? If the latter then show us an example of what you want the query to be, and where the variable part comes from.

This is about an energy display, NodeRed-Influxdb-Grafana. I am retriving the energy prices via the "Nordpool-node" which is inserting the prices in influx with the node-red-contrib-influxdb node. This is specified in a Function node where every hour get its own field key with a "general" timestamp for all field keys. This is actually working, I get new prices every midnight inserted in the database as desired.

I would then like to get back the price hour by hour with a SELECT nphour[hr] FROM energyprice where nphour is the field key and hr is the actual hour stated in another Function node. Here is obviosly the problem, with this hr-variable. I have tried a lot of "('[{-setups but nothing seems to work, I can not find any helpful info at the

Any ideas would be so much appreciated!

This is done with version 1.8 installed one month ago.

What are the actual key names? Always try and give real examples in cases like this, so there is no confusion about what you actually mean.

Key names in database is: nphour00, nphour01... nphour23, is the last one.

When I write eg SELECT nphour14 FROM energyprice I get the right value replied.

Use a Template node to build the query to pass to the influx node. The template node help text shows how to do that

You can do something like this, I don't know how the rest of your flow looks like but this should give you an idea of what to do.

[{"id":"abcdd40cf46442c7","type":"inject","z":"5924732647e43e8f","name":"11","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"11","payloadType":"num","x":390,"y":880,"wires":[["02e37dc5bb0c1f81"]]},{"id":"b3d35fe7e04bb93f","type":"inject","z":"5924732647e43e8f","name":"12","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"12","payloadType":"num","x":390,"y":920,"wires":[["02e37dc5bb0c1f81"]]},{"id":"70a3fabcb3f85a77","type":"inject","z":"5924732647e43e8f","name":"20","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":390,"y":980,"wires":[["02e37dc5bb0c1f81"]]},{"id":"02e37dc5bb0c1f81","type":"function","z":"5924732647e43e8f","name":"function 13","func":"\nmsg.query = \"SELECT nphour\" + msg.payload +\" FROM energyprice\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":940,"wires":[["4f7bd9d0738230c9"]]},{"id":"4f7bd9d0738230c9","type":"debug","z":"5924732647e43e8f","name":"debug 20","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":940,"y":940,"wires":[]}]

Finally I got it to work. Thank you so much for your assistance!!!

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