Closed Sukalo0290 closed 3 years ago
Your data is recognised as string and not as JSON.
What is your commandline to send the data to node red? Whats inside your callback script? Did you edit the IP address to point to your Node-RED instance?
So i imported the Callback file which populates all the nodes for me, I then deploy and press the start button then it produces the string as you say in the debug window.
I haven't done anything else.
You have to edit sendToNodeRed.sh because there is the configuration with IP address to Node-RED.
Okay, what do i need to edit exactly? I tried adding my ddns url and replacing the ip but got this message. Not 100% what i'm meant to edit. Sorry
HTTP/1.1 401 Unauthorized
X-Powered-By: Express
Access-Control-Allow-Origin: *
WWW-Authenticate: Basic realm="Authorization Required"
Content-Type: text/plain; charset=utf-8
Content-Length: 12
ETag: W/"c-dAuDFQrdjS3hezqxDTNgW7AOlYk"
Date: Sun, 23 May 2021 12:50:21 GMT
Connection: keep-alive
Unauthorized
If i head to the url i also get this message.
Cannot GET /MiTemperature2Input
This is sendToNodeRed.sh
Please edit at the places in angle brackets < >
#!/bin/bash
#use e.g with that script: MySensor.sh
#!/bin/bash
#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
#$DIR/LYWSD03MMC.py --atc --watchdogtimer 5 --callback sendToNodeRed.sh
if [[ "$1" == *"rssi"* ]]
then
curl -s -i -XPOST http://<YOURHOST>:<YOURPORT>/MiTemperature2Input -H "Content-Type: application/json" --data "{\"sensor\": \"$2\", \"temperature\" : $3 , \"humidity\" : $4 , \"voltage\" :$5, \"rssi\" : $6, \"timestamp\": $7 }"
else
curl -s -i -XPOST http://<YOURHOST>:<YOURPORT>/MiTemperature2Input -H "Content-Type: application/json" --data "{\"sensor\": \"$2\", \"temperature\" : $3 , \"humidity\" : $4 , \"voltage\" :$5, \"timestamp\": $6 }"
fi
Please also make sure that the file is executable.
You can try input via curl -s -i -XPOST http://<YOURHOST>:<YOURPORT>/MiTemperature2Input -H "Content-Type: application/json" --data "{\"sensor\": \"test\"}
Then something like
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
Content-Length: 17
ETag: W/"11-fyHJk+dvAhap7G9YWDp+qFaW45w"
Vary: Accept-Encoding
Date: Mon, 24 May 2021 19:45:47 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"sensor":"test"}
should be returned.
Thanks for the response, i have actually managed to get the MQTT working today so now i'm trying to connect the influxdb so i can show the results on grafana or something but there doesn't seem to be any input yet so still working on it. I'm sure i'll be back if can't sort it.
Apologies, i'm pretty new to all this. I'm struggling with MQTT so using the Callback flow.
I want to display the gauges and charts directly on the Node Red Dashboard so i have two questions about this. firstly the device is connecting and bringing in the advertisements using the atc, the packet seems to be split up firstly which is proving difficult to use the split or function to extract the individual measurements to send the temperature to one graph and humidity to another.
Also where is this data or how to i setup the http as i don't seem to get any data from this area.
Thanks for any assistance.