Added MQTT support

:smiley:

Beside LOL something has coming up in Node-Red :smiley:

Some errors (as always)

MQTTout:{“date”:%date%}
MQTTout {“date”:19/8/2019}
Unexpected token / in JSON at position 10

MQTTout:{“time”:%time%}
MQTTout {“time”:13:29}
Unexpected token : in JSON at position 10

MQTTout:{“temp”:%temp%}
MQTTout {“temp”:20.2}

MQTTout:{“hum”:%hum%%}
MQTTout {“hum”:69%}
Unexpected token % in JSON at position 9

MQTTout:{“rain”:%dayrn%}
MQTTout {“rain”: 0.4}

MQTTout:{“Wind”:%currbftspeed%,%dirlabel%}
MQTTout {“Wind”:1 bft,SW}
Unexpected token b in JSON at position 10

MQTTout:{“soil”:%soilmoistpercent%}
MQTTout {“soil”:-27.5}

MQTTout:{“baro”:%baro%}
MQTTout {“baro”:1012.8}

MQTTout:{“cloud”:%Currentsolardescription%,%cloudheightmeters%m,%Currentsolardescription%}
MQTTout {“cloud”:Zonnig/Droog,737m,Zonnig/Droog}
Unexpected token Z in JSON at position 9

MQTTout:{“UV waarde”:%VPuv%}
MQTTout {“UV waarde”:3.6}

MQTTout:{“Solar”:%VPsolar%W/m2}
MQTTout {“Solar”:657W/m2}
Unexpected token W in JSON at position 12

What I notice
Problems with
Capitals
:
%
how to resolve those unexpecteds ?

Glad to have output anyway

Thanx in advance !

Old grey :wink:

Ed

you are getting closer…

MQTTout:{“date”:%date%}
MQTTout {“date”:19/8/2019}
Unexpected token / in JSON at position 10

Try to handle this as a string, i.e. replace %date% with “%date%”

MQTTout:{“time”:%time%}
MQTTout {“time”:13:29}
Unexpected token : in JSON at position 10

Try to handle this as a string, i.e. replace %time% with “%time%”

MQTTout:{“temp”:%temp%}
MQTTout {“temp”:20.2}

MQTTout:{“hum”:%hum%%}
MQTTout {“hum”:69%}
Unexpected token % in JSON at position 9

MQTTout:{“rain”:%dayrn%}
MQTTout {“rain”: 0.4}

MQTTout:{“Wind”:%currbftspeed%,%dirlabel%}
MQTTout {“Wind”:1 bft,SW}
Unexpected token b in JSON at position 10

Try to handle this as a string, or split this into 2 different key/value pairs, both of which would have to be strings

MQTTout:{“soil”:%soilmoistpercent%}
MQTTout {“soil”:-27.5}

MQTTout:{“baro”:%baro%}
MQTTout {“baro”:1012.8}

MQTTout:{“cloud”:%Currentsolardescription%,%cloudheightmeters%m,%Currentsolardescription%}
MQTTout {“cloud”:Zonnig/Droog,737m,Zonnig/Droog}
Unexpected token Z in JSON at position 9

Try to handle this as a string i.e. enclose the entire value between 2 double quotes

MQTTout:{“UV waarde”:%VPuv%}
MQTTout {“UV waarde”:3.6}

MQTTout:{“Solar”:%VPsolar%W/m2}
MQTTout {“Solar”:657W/m2}
Unexpected token W in JSON at position 12

Try to handle this as a string i.e. enclose the entire value between 2 double quotes

Let me know how it goes

Renato

Thanks so much Renato no more errors Whoopie !!!

Depending to your post above:

To get it in ‘an InfluxDB TimeSeries database rendered on the Grafana dashboard’ as you ment, do I have to expand NODE-Red as in your setting (except Strip leading text) ?
See both attachements.

I’m afraid I have to refer to your Grafana as I get a bad gateway with my settings as shown att 3.

Yes getting closer !!


Ed

this is the flow and other configurations I use now:

Home this helps.

Renato


Node-Red InfluxDB Out Node.png

ok will investigate !

Later ! days I think the wife just has priority to take the tube to Amsterdam tomorrow (takes 12 minutes btw :-).) Nice too!

Maybe I’m missing some here #-o

I still get a bad gateway error in influxdb with this settings
see att 1

As I see in your example (thanks !) there is an influxdb node for output, but I don’t have that in my nodes list
see att 2

installing from -flows.nodered.org/node/node-red-contrib-influxdb- does not change available nodes as shown at that page
see att 3

missing what or am I missing something in my head/eyes 8O


Ed

Are you sure about the port number you are using for InfluxDB? You are using 1883. Typically that is the port number for MQTT. Where/how did you install InfluxDB? Was it a docker installation of a bare metal installation?

InfluxDB default http port is 8086 https://docs.influxdata.com/influxdb/v1.7/administration/ports/

Renato

:lol:
from here https://iotbyhvm.ooo/influxdb-time-series-datbase/

InfluxDB default http port is 8086 [https://docs.influxdata.com/influxdb/v1.7/administration/ports/](https://docs.influxdata.com/influxdb/v1.7/administration/ports/)
:oops: :oops: :oops: aha now I get database not found !

remains (I hope) the last question:
wich node do I choose to send data to the database ?

thanks again !!!

Ed

  1. Have you created a database?
  2. Does the user “Pi” have write privileges on that database?

As for your question, you would connect the InfluxDB out object to the json object.

Renato

found this https://developers.bigclown.com/integrations/grafana-for-visualization

2) Does the user "Pi" have write privileges on that database?
were to set that ?
As for your question, you would [b]connect the InfluxDB out object to the json object[/b].
hm with the node from your example (see att) I was looking for that but could not resolve it. Which one in the output? As said in my reply I dont have such one in the list.

Oh boy oh boy lead me by the hand please


Node-Red InfluxDB Out Node.png

Ed

let’s address one thing at a time.

I suggest you read this https://robpol86.github.io/influxdb/config.html or any other link.

In summary:

  1. From the linux prompt, start the influxdb CLI: by typing in “influx” (without quotes)
  2. Once inside the CLI, create a database by issuing: CREATE DATABASE weather_display
    3a) create a use and grant privileges to it: CREATE USER username WITH PASSWORD ‘password’
    3b) GRANT ALL ON weather_display TO username

Next
try to connect to the database from grafana. Does it work?

Renato

try to connect to the database from grafana. Does it work?

Yess, ‘data source is working’ now

Ed

next, drop in an InfluxDB out object on the Node Red flow. Connect it to the database (same as you did in Grafana). Connect your json object to the influxDB object and commit your changes.

Use my flow as a guide.

Renato

will work on it tomorrow !!

bed time here

thanks

ed

I am trying to get only to values from the WDs MQTT messages.
I have Mosquitto, node-red, mysql and grafana running.
I have several esp8266 sening mqtt mesages and then I put them into my mysql db.
Now I “only” need help with node-red to just get me the values from example the temp message.
The message look like this:
WeatherDisplay/temp {“temp”:“16.6”}

I would like just the value 16.6

I have tried JSON, SWITCH and Change nodes but with no luck.
I am probaly doing something wrong

Sorry to bump it up but still strugling ! Last try

What means :

Error: A 400 Bad Request error occurred: {“error”:“error parsing query: found nieuwendam, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1”}

see att

thanks !


What does the last node do ?
Dont recognise that node ?

Ed

You are using the wrong influxdb object.

Look back at my flow.

You should use the node with the “hexagon” icon on the right NOT the one on the left.

Look for the one called “influxdb out”

Renato

Thanks guys still alive with this !!

Quart : forget my post wrong setting :oops:

Renato
thanks for your patience as well !

Changed to node with hexagon on the right (end node yes)

I now have log files in Granada (see att 1)

This is my flow Node Red (with properties) att 2

so that works

but still no data in graph files att 3

working on it !