• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Signal K MQTT Node Red
#1
Hi,

there is no manual for MQTT on openplotter 1.0.0..
Have tried the following:

In MQTT username and password entered.
[Image: openplotter1.png]
Is the Type K key input correct, or is the signal K delta input or General?

[Image: openplotter2.png]

Try General.

[Image: openplotter3.png]

navigation.gnss.satellites are currently 8.

[Image: openplotter4.png]
 Then I choose in openplotter "Action" and add to create a trigger.
As Sinal K key I choose navigation.gnss.satellites. Can you test well at home. Move the GPS a bit away from the window and the number of satellites changes.
As the value I choose <10.

[Image: openplotter5.png]
Then click add under action.
In the selection, take "Publish on topic: satellites".
Then click on "Appley changes".

What happens now? Nothing.
Where does the edition take place?

Try Node-Red.

Drag Input Mqtt element onto the surface.
Enter as Topic satellites.
[Image: openplotter6.png]
Drag the output debug element onto the surface and connect the nodes.
Click on "Deploy". If then under satellites connected, the connection should be OK.
If I open the debug window, nothing happens.
What did I not understand?
  Reply
#2
EXAMPLES

this will get data from websocket and send mqtt...change security on mqtt node.do this with any sk values.
then subscribe to in op mqtt tab. lat or lon
i don't see where you are publishing any thing for node-red to receive .what triggers the action.? trigger no action.?

Code:
[{"id":"8f31d493.476948","type":"websocket in","z":"5184beb.49c6e4","name":"ws","server":"f3d9cf91.f4f67","client":"","x":110,"y":100,"wires":[["bd528bda.f3c1a8"]]},{"id":"bd528bda.f3c1a8","type":"jsonpath","z":"5184beb.49c6e4","expression":"$.updates..values[*]","split":false,"name":"Signal K delta values","x":283,"y":100.99999523162842,"wires":[["9a42e3b.910882"]]},{"id":"9a42e3b.910882","type":"function","z":"5184beb.49c6e4","name":"merge values","func":"var paths={};\nvar arrayLength = msg.payload.length;\nfor (var i = 0; i < arrayLength; i++) {\n    paths[msg.payload[i].path]=msg.payload[i].value;\n}\nmsg.payload = paths;\nreturn msg;","outputs":1,"noerr":0,"x":480,"y":100,"wires":[["62069dc0.061724","3feaacd.3c89854"]]},{"id":"62069dc0.061724","type":"function","z":"5184beb.49c6e4","name":"navigation.position.latitude","func":"var signalk_key=\"navigation.position\";\n\nif(msg.payload.hasOwnProperty(signalk_key)){\n    msg.payload=msg.payload[signalk_key][\"latitude\"];\n    return msg;\n}","outputs":1,"noerr":0,"x":720,"y":80,"wires":[["8af871d6.b997b"]]},{"id":"3feaacd.3c89854","type":"function","z":"5184beb.49c6e4","name":"navigation.position.longitude","func":"var signalk_key=\"navigation.position\";\n\nif(msg.payload.hasOwnProperty(signalk_key)){\n    msg.payload=msg.payload[signalk_key][\"longitude\"];\n    return msg;\n}","outputs":1,"noerr":0,"x":720,"y":120,"wires":[["a914ee48.a0d17"]]},{"id":"8af871d6.b997b","type":"mqtt out","z":"5184beb.49c6e4","name":"lat","topic":"lat","qos":"0","retain":"","broker":"dcdf2343.034d1","x":920,"y":80,"wires":[]},{"id":"a914ee48.a0d17","type":"mqtt out","z":"5184beb.49c6e4","name":"","topic":"lon","qos":"0","retain":"","broker":"dcdf2343.034d1","x":920,"y":120,"wires":[]},{"id":"f3d9cf91.f4f67","type":"websocket-listener","z":"","path":"ws://localhost:3000/signalk/v1/stream","wholemsg":"false"},{"id":"dcdf2343.034d1","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
[*]


this gets a message from an esp 8266 "espeasy"and publish on mqtt with a simple topic 
and a dash board widget.

Code:
[{"id":"8f023220.4d53e","type":"mqtt in","z":"46d7f9c0.e081c8","name":"","topic":"/ESP03/watertemp/Temperature","qos":"0","broker":"cf4d901f.78107","x":150,"y":1040,"wires":[["62ecfd4.b8d7f04","468dce85.5db9e"]]},{"id":"c1a2913d.efe5","type":"function","z":"46d7f9c0.e081c8","name":"","func":"msg.value=msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":514.000316619873,"y":1037.0001249313354,"wires":[["218c4083.ea80a"]]},{"id":"468dce85.5db9e","type":"debug","z":"46d7f9c0.e081c8","name":"","active":false,"console":"false","complete":"false","x":530,"y":1140,"wires":[]},{"id":"62ecfd4.b8d7f04","type":"function","z":"46d7f9c0.e081c8","name":"C  to F","func":"\n\nvar temp = msg.payload;\n\nvalue = (temp * 9.0) / 5.0 + 32.0; \nmsg.payload=value;\nreturn msg; ","outputs":1,"noerr":0,"x":378.000244140625,"y":1038.000096321106,"wires":[["c1a2913d.efe5","6953283a.7a5d88"]]},{"id":"6953283a.7a5d88","type":"mqtt out","z":"46d7f9c0.e081c8","name":"","topic":"watertemp","qos":"","retain":"","broker":"cf4d901f.78107","x":530,"y":1080,"wires":[]},{"id":"218c4083.ea80a","type":"ui_chart","z":"46d7f9c0.e081c8","name":"","group":"13514fc5.25604","order":1,"width":0,"height":0,"label":"tempwater","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":775.000410079956,"y":1090.0000982284546,"wires":[[],[]]},{"id":"cf4d901f.78107","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"13514fc5.25604","type":"ui_group","z":"","name":"SECURITY","tab":"eab91d6c.e8134","order":2,"disp":true,"width":"6"},{"id":"eab91d6c.e8134","type":"ui_tab","z":"","name":"Tab 2","icon":"dashboard","order":2}]

http://forum.openmarine.net/showthread.php?tid=1032
  Reply
#3
Hi,

Must have understood something yet.

In openplotter MQTT.
Username and password set, so connect with Local Brocker.
Topic created:
topic "satellites" of type "General" and signal K key is "notification.satellites" Source "MQTT.satellites".

In openplotter actions.
Trigger created:
trigger "navigation.gnss.satellites.value" operator <10 and the action "Publish on topic: satellites" data as a test is string "Sattellites <10" repeat 1.0 seconds.

In Node Red.
MQTT input created:
The MQTT input from Node Red has the topic "satellites" and is linked to the MQTT local broker.
Debug Node msg.payload.

I assume that the local Brocker passes the action "topic.satellites" to the MQTT input of Node red.
But he probably does not, right?
Here is probably a mistake.
  Reply
#4
you cant publish from the actions tab..

   
i don't see any action to publish mqtt.
in fact i don't think op can publish mqtt at all you need to do it in node-red


 you can only have one "ws"web socket so delete any others and change user pass in the ...mqtt ..NODE...select the pencil choose localhost 1883 and in security your user and pass  to be same as openplotters mqtt
here 
Code:
[{"id":"bc03edcb.cacb7","type":"websocket in","z":"aceda197.5265b","name":"ws","server":"f3d9cf91.f4f67","client":"","x":90,"y":160,"wires":[["e5da9f1.2a8806"]]},{"id":"e5da9f1.2a8806","type":"jsonpath","z":"aceda197.5265b","expression":"$.updates..values[*]","split":false,"name":"Signal K delta values","x":263,"y":160.99999523162842,"wires":[["42cab5e3.61144c"]]},{"id":"42cab5e3.61144c","type":"function","z":"aceda197.5265b","name":"merge values","func":"var paths={};\nvar arrayLength = msg.payload.length;\nfor (var i = 0; i < arrayLength; i++) {\n    paths[msg.payload[i].path]=msg.payload[i].value;\n}\nmsg.payload = paths;\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":160,"wires":[["3fe12873.1cbcd8"]]},{"id":"3fe12873.1cbcd8","type":"function","z":"aceda197.5265b","name":"compass","func":"var signalk_key=\"navigation.gnss.satellites\";\n\nif(msg.payload.hasOwnProperty(signalk_key)){\n    msg.payload=msg.payload[signalk_key];\n    return msg;\n    \n\n}","outputs":"1","noerr":0,"x":620,"y":160,"wires":[["7e5ba565.1a0fec"]]},{"id":"7e5ba565.1a0fec","type":"mqtt out","z":"aceda197.5265b","name":"","topic":"satellites","qos":"","retain":"","broker":"dcdf2343.034d1","x":760,"y":160,"wires":[]},{"id":"f3d9cf91.f4f67","type":"websocket-listener","z":"","path":"ws://localhost:3000/signalk/v1/stream","wholemsg":"false"},{"id":"dcdf2343.034d1","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
[*]
now subscribe in op's mqtt TAB.


mqtt is just publish and subscribe....EZ.

[*]    
  Reply
#5
(06-09-2018, 04:36 AM)wkmhv Wrote: topic "satellites" of type "General" and signal K key is "" Source "MQTT.satellites".


......
I assume that the local Brocker passes the action "topic.satellites" to the MQTT input of Node red.

Other way round I think, notification.satellites gets set to the value of MQTT.satellites.

I use that to get data into signalk from an ESP8266 using MQTT over wifi.
  Reply
#6
now a trigger and action

set up the trigger

   

highlight the trigger and add an action this is a message action
as always apply new settings... close op

   

stop all actions and start again from desktop "OK"OK".... wait.... if it triggers get this

   

if you have a prob.check the action was applied or you may need to reboot
  Reply
#7
Hi jim321,

I know Your "It works" sample really works fine.
I have done it already with an action send mail. It works without any settings in op's MQTT tab.

But i like to send this message to node red, which unfortunatelly still not work.
  Reply
#8
(06-09-2018, 11:59 AM)wkmhv Wrote: Hi jim321,

I know Your "It works" sample really works fine.
I have done it already with an action send mail. It works without any settings in op's MQTT tab.

But i like to send this message to node red, which unfortunatelly still not work.

If you trigger a  command, it should work.
mosquitto_pub -h 10.10.10.1 -t /test/anytopic -u pi -P raspberry -m anymessage
But first: sudo apt-get install mosquitto-clients
  Reply
#9
(06-09-2018, 11:59 AM)wkmhv Wrote: Hi jim321,

I know Your "It works" sample really works fine.
I have done it already with an action send mail. It works without any settings in op's MQTT tab.

But i like to send this message to node red, which unfortunatelly still not work.

This should put all signalk messages into node red global variables, then use an inject node to use them. 
Code:
[{"id":"a89980ea.5e66c","type":"function","z":"749e8283.293f4c","name":"Create global variable","func":"// \n\n    if (typeof msg.payload.updates !== 'undefined') {\n         \n            obj=msg.payload.updates[0].values[0].path;\n            value=msg.payload.updates[0].values[0].value;\n            global.set(obj, value);\n            msg.payload =  value;\n            msg.topic = obj;\n           \n            \n        \n        return [ null, msg ];\n    } \n","outputs":"2","noerr":0,"x":420,"y":80,"wires":[[],["fe0ec8cb.b88868"]]},{"id":"20af45d9.7fe30a","type":"json","z":"749e8283.293f4c","name":"","pretty":false,"x":230,"y":80,"wires":[["8b385a5c.b0c248","a89980ea.5e66c"]]},{"id":"fe0ec8cb.b88868","type":"debug","z":"749e8283.293f4c","name":"","active":false,"console":"false","complete":"true","x":530,"y":180,"wires":[]},{"id":"67b79641.1fad68","type":"websocket in","z":"749e8283.293f4c","name":"SignalK input","server":"fc1b2b62.0b63a8","client":"","x":90,"y":80,"wires":[["20af45d9.7fe30a","5235ae78.9cab4"]]},{"id":"8b385a5c.b0c248","type":"link out","z":"749e8283.293f4c","name":"To database","links":["1297a3e2.92bf2c","3e1e107d.03f6f"],"x":355,"y":120,"wires":[]},{"id":"5235ae78.9cab4","type":"debug","z":"749e8283.293f4c","name":"","active":false,"console":false,"complete":"true","x":130,"y":160,"wires":[]},{"id":"fc1b2b62.0b63a8","type":"websocket-listener","z":"","path":"ws://localhost:3000/signalk/v1/stream","wholemsg":"false"}]
  Reply
#10
"But i like to send this message to node red, which unfortunately still not work."

you can get all sk data into node red with the websocket stream.
exactly what are you trying to do?? i'll try to help..

@JeroenAdam
i'll try that
thanks
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)