You are not logged in.
Pages: 1
Topic closed
I would like to use a HTTP API to send some data to another application, this data should be placed in the body of the POST url.
The data string (JSON like) looks something like this...
[
{
"name" : "temperatures",
"columns" : ["bedRoom", "kitchen", "bathRoom"],
"points" : [
[sensor0, sensor1, sensor2]
]
}
]
How do I get my my data (sensor0, sensor1, sensor3) inside this string? Can I accomplish this in the REXLANG function block?
Offline
Hi scoobsalamander,
thank you for your question about our new feature - Strings. If I understood correctly, the function block you are looking for is "CONCAT" from "STRING" library. This block concatenates input strings according to given pattern. The functionality you would like to achieve is shown in REST API example on our GitHub.
There is also suitable function in REXLANG called "strcat(dest,src)", which appends "src" string to "dest" string.
Hope that I answered your question. If you require any further information, feel free to contact me.
Cheers, Tomas
Offline
...thanks for the link. My locally stored Github forked files of the examples seemed to be outdated......ok now. :-)
I'm trying to send some sensor data to an external storage engine (influxdb running on the same device). With node-red it is working fine but now I would like to send it straight from REXcontrols to this time series database.
I tried already a lot but I always get an error....the parser on influx' side is throwing errors all the time.
If someone has an idea how I should format the data (4 floats) to get it into my database???
I already tried with single points and multiple.....tried also a string which I found on their website but only errors are being send back.
Is it because it is not real Json (they are using line protocol now instead of Json)?
Offline
....after a good sleep I had some success with storing values directly into a Influx DB.
(Only the conversion of the values I still have to check because something has gone wrong .....see for example the values 2,3 & 5...they do not correspond)
** EDIT : changed settings of RTOS function blocks inside the Subsystem. Now the values are OK. (corrected in example as well...)
Example :
InfluxDB.zip
Influx database used in example : REXmeas
IP-address of InfluxDB : localhost
Influx info - data format --> 'line protocol' is used instead of JSON (deprecated as of InfluxDB 0.9.1), if you use Node-RED then you still can use JSON.
Last edited by scoobsalamander (2016-12-16 14:18:03)
Offline
Hi scoobsalamander,
thank you for sharing your project with the community - it can be valuable source for someone else. Your pace is incredible Keep up!
Cheers, Tomas
Offline
Is there possible to implement Jason on Modbus protocol ?
In that way, it might send both control command and data at the same time.
Most importantly, using Jason to define tags for others undefined devices of automation and IoTs.
Offline
Json is a text string which contains the data. So for automation I would opt for Modbus..... With Json you need the convert your integers and booleans first into a string and afterwards another conversion is needed.....not so efficient.
In this topic I was just showing how you can use it to store some data in a database every few seconds/minutes.....
Do you have an example of the data which you would like to send? This might give us a better idea what you are trying to achieve....
Offline
Pages: 1
Topic closed