Extract sensor values in Node-red
-
If you switch to mqtt gateway, you could just link the gauge to the topic of the sensor and you are done
-
https://www.mysensors.org/build/mqtt_gateway
it is pretty much the same as the ethernet, it just needs a few extra parameters and an mqtt broker running somewhere (if you already have a RPI, just install mosquitto)
-
I don't remember how to use the mysensors nodes, but knowing how mqtt works, just take advantage of it: the sensor is publishing a value to a topic, so just read that.
@gohan I am just thinking about the implications of moving to mqqt. This will break my home assistant setup. I also have over 30 sensors I would have to change the setup of.
If you see this as an example, "67;0;1;0;0;62.5↵" which is my data from a sensor showing in node-red debug. The 67 is the nodeId, the next 0 is the childSensor Id and the 62.5 is the temperature.
This the code I am using in a function of node-red to try and extract the temp value.
if (msg.payload.nodeId == 67 && msg.payload.childSensorId === 0) {
var msg;
msg.payload = msg.payload.value;
msg.topic = "Temperature";
return msg;
}Can anyone spot any reason why this may not work ?
-
I have built an Mqtt gateway as you suggested. from the arduino serial monitor I can see it working, as below.
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.5
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.0
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.5
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.0
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=5,c=1,t=0,ptto=7,l=5,sg=0:16.5
0;255;3;0;9;Sending message on topic: mygateway1-out/67/5/1/0/0I have mosquitto broker running on my pi 3. Node-red shows connected to the mqqt broker, yet no data is shown passing.
any ideas how best to fault find this issue
-
@gohan I am just thinking about the implications of moving to mqqt. This will break my home assistant setup. I also have over 30 sensors I would have to change the setup of.
If you see this as an example, "67;0;1;0;0;62.5↵" which is my data from a sensor showing in node-red debug. The 67 is the nodeId, the next 0 is the childSensor Id and the 62.5 is the temperature.
This the code I am using in a function of node-red to try and extract the temp value.
if (msg.payload.nodeId == 67 && msg.payload.childSensorId === 0) {
var msg;
msg.payload = msg.payload.value;
msg.topic = "Temperature";
return msg;
}Can anyone spot any reason why this may not work ?
@lozzer65 I'm playing with node red and a mock TCP gateway at the moment and looking at your code I think the problem is that rather than msg.payload.nodeId it should be msg.nodeId and msg.payload.childSensorId should be msg.childSensorId. I realise you've moved on to MQTT but thought I'd mention it in case others come looking.
-
If you use the node-red-contrib-mysensors nodes, then you can split the sensor string into the different parts.
Then you are able to use for example the switch node, to filter the data..

-
Sorry I don't have more documentation at hand, than what is in the mysensors npm module already. But basically I use the switch node to route messages, on subtype, then on nodeId, and last on childId.
I'm currently remodeling my node-red setup.. Moving everything to MQTT for internal message distribution between all parts (both within node-red and to external systems).
-
Sorry I don't have more documentation at hand, than what is in the mysensors npm module already. But basically I use the switch node to route messages, on subtype, then on nodeId, and last on childId.
I'm currently remodeling my node-red setup.. Moving everything to MQTT for internal message distribution between all parts (both within node-red and to external systems).
-
I have put my nodered flows on github as a project, where you can clone from, find it at https://github.com/tbowmo/nodered-mysensors-flow
Please note that this is taylored specifically to my usage, but could be used as an inspiration..
(In nodered 0.18.x they have added possibility to have multiple projects, including git and github integration)
-
I have put my nodered flows on github as a project, where you can clone from, find it at https://github.com/tbowmo/nodered-mysensors-flow
Please note that this is taylored specifically to my usage, but could be used as an inspiration..
(In nodered 0.18.x they have added possibility to have multiple projects, including git and github integration)