ruudverheijden / node-p1-reader

Node.js package for reading and parsing data from the P1 port of a Dutch or Belgian Smart Meter.
MIT License
25 stars 25 forks source link

Using P1 node over TCP with ser2net #22

Open albertjve opened 2 years ago

albertjve commented 2 years ago

Hi Ruud, I have pi2 that is in my meter closet that is not running Node Red. I want to use it to bridge the serial P1 data over TCP using ser2net to the machine that runs node red.(How) Can this be done? Could I simply direct the p1 node to IP:port?

Alternatively I can tunnel the serial port via ser2net to the other machine, but this seems more complicated and requires more configuration than the option above. I hope you can help.

Kind regards, Albert

ruudverheijden commented 2 years ago

Hi Albert,

I'm not familiar with ser2net but what I quickly read is that is send the raw serial port data over IP. This Node.js library parses serial data directly from a connected physical usb/serial port so that would not work.

So I guess you have 2 options: use ser2net and write your own serial parser to make sense out of the data (you can copy paste some logic of this library for the parsing), OR run a node.js script on the machine that is connected to the P1 port and let this library do it's magic :)

In the latter case you would need to have some input / listener defined in Node Red. A quick and dirty way could be to use the HTTP GET input of Node Red, copy the example.js file in this repo and extend that to make a GET request to the Node Red server. Then run that script on the Pi2 in the meter closet.

Off course HTTP has quite a lot of overhead so something like MQTT might be more appropriate but that would require an additional broker.

Good luck!

Ruud

timoline commented 2 years ago

This is possible, I use it over here. P1 data is sent over ser2net. Node-red picks up the data (Node-red TCP in) and the packetParser lib (Node-red function) from Ruud is parsing the data to an object. :-)

jeroenkl commented 1 year ago

uick and dirty way could be to use the HTTP GET input of Node Red, copy the example.js file in this repo and extend that to make a GET request to the Node Red server. Then run that script on the Pi2 in the meter closet.

Hi Timoline, Due to limited node-red knowledge, could you please help, provide, shows your parser file? I have the P1 Raw data available in node-red.

thxs, much appreciated, Jeroen

timoline commented 1 year ago

here is the flow flows.zip

Giel538 commented 1 year ago

here is the flow flows.zip

Hi, thanks for this flow! It is realy great.

My skills are also limited but is it possible to modify the flatten function a bit so it removes all the lines with .unit and were the reading is null. This will reduce the mqtt load a lot.