ESPeasy and P1 smart meter MQTT

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
egbert
Normal user
Posts: 2
Joined: 11 May 2017, 13:32

ESPeasy and P1 smart meter MQTT

#1 Post by egbert » 11 May 2017, 13:58

Hi. New here.
I'm trying to get an ESP-01 with ESPeasy 2.0.0-dev8 configured in such a way that it will accept the P1 message from my smart meter (LandysGyr 4.2) and PUBlish it, as is, to my MQTT server/broker on a Raspberry pi. Publishing sysinfo/uptime works fine. The hardware to invert the serial stream from P1 works too. Output is 5V with the bursts going to 0V. I hoped to use device "P1 meter..." but I seem not able to get it right. There is not much doc...(should I read source?)

Does the P1 plugin only work with Domoticz? I've configured' OpenHab as server/brooker which works fine for sysinfo. SUBbing to the right topic on the CLI of the Rpi shows the uptime in minutes as expected.

Martinus

Re: ESPeasy and P1 smart meter MQTT

#2 Post by Martinus » 13 May 2017, 11:38

The P1 gateway acts as a TCP <-> Serial bridge, so it can only be used on controllers that allow to connect to some P1 interface that acceps TCP (telnet like) connections. Domoticz supports this, i do not know about any other that does...
Using MQTT is currently not possible with this plugin. It would need to be changed to be able to select between sending the serial input buffer data through an open TCP connection or send it on a MQTT channel...

egbert
Normal user
Posts: 2
Joined: 11 May 2017, 13:32

Re: ESPeasy and P1 smart meter MQTT

#3 Post by egbert » 13 May 2017, 11:50

Dank je Martinus. Looking thru the source gave me that impression already. Since in 2.0.0 a clear separation is made between the data gathering part and the data transmission part, I hoped that chooing another "controller" would do the trick. Not :(
I do need a serial (blub with P1 message) to native MQTT or OpenHab/MQTT. Programming this plugin myself is a bridge too far, I'm affraid. This ESP and event driven stuff is very new to me.
Greetings, Egbert Jan, NL

Tecumseh
Normal user
Posts: 28
Joined: 30 Sep 2016, 09:42

Re: ESPeasy and P1 smart meter MQTT

#4 Post by Tecumseh » 13 Sep 2017, 21:58

This explains not getting the MQTT publish of my P1 readings working. Any progress on getting some sort of info towards Openhab?

Tecumseh
Normal user
Posts: 28
Joined: 30 Sep 2016, 09:42

Re: ESPeasy and P1 smart meter MQTT

#5 Post by Tecumseh » 17 Sep 2017, 19:50

After some trial and error attempts to use Node RED to parse the data I have had some success. I have pasted the Node-RED configuration I've created. As my knowledge for javascript is limited tips for improvements are most welcome.

Code: Select all

[{"id":"b233928e.ce6fc","type":"tcp in","z":"701b8944.916b58","name":"Node-RED Client","server":"client","host":"192.168.178.16","port":"8088","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"P1","base64":false,"x":100,"y":60,"wires":[["8d63c2a5.674b9"]]},{"id":"8d63c2a5.674b9","type":"function","z":"701b8944.916b58","name":"Trim","func":"msg.payload = msg.payload.trim();\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":60,"wires":[["1b090555.29792b"]]},{"id":"1b090555.29792b","type":"switch","z":"701b8944.916b58","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"1-0:1.8.1","vt":"str"},{"t":"cont","v":"1-0:1.8.2","vt":"str"},{"t":"cont","v":"1-0:1.7.0","vt":"str"},{"t":"cont","v":"1-0:2.8.1","vt":"str"},{"t":"cont","v":"1-0:2.8.2","vt":"str"},{"t":"cont","v":"1-0:2.7.0","vt":"str"},{"t":"cont","v":"0-1:24.2.1","vt":"str"},{"t":"else"}],"checkall":"true","outputs":8,"x":90,"y":260,"wires":[["a54ea4e4.1dcd88"],["ad0fa246.c824a"],["aa070718.aa29e8"],["73857243.28640c"],["a43d5591.56ed18"],["8dedc450.0d4a08"],["a4844f32.35c72"],["c3a5f168.e0645"]]},{"id":"c3a5f168.e0645","type":"debug","z":"701b8944.916b58","name":"Overig","active":false,"console":"false","complete":"payload","x":290,"y":420,"wires":[]},{"id":"d0a16e08.1086a","type":"comment","z":"701b8944.916b58","name":"DSMR v4.0","info":"1-0:1.8.1 = Elektra verbruik laag tarief (DSMR v4.0)\n1-0:1.8.2 = Elektra verbruik hoog tarief (DSMR v4.0)\n1-0:1.7.0 = Elektra actueel verbruik (DSMR v4.0)\n1-0:2.8.1 = Elektra teruglevering laag tarief (DSMR v4.0)\n1-0:2.8.2 = Elektra teruglevering hoog tarief (DSMR v4.0)\n1-0:2.7.0 = Elektra actueel teruglevering (DSMR v4.0)\n0-1:24.2.1 = Gas (DSMR v4.0)","x":530,"y":60,"wires":[]},{"id":"a54ea4e4.1dcd88","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":140,"wires":[["c9e893ae.08c4b"]]},{"id":"ad0fa246.c824a","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":180,"wires":[["b05d2ce4.6e103"]]},{"id":"aa070718.aa29e8","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":220,"wires":[["29d5618a.90cc1e"]]},{"id":"73857243.28640c","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":260,"wires":[["9957689f.adf378"]]},{"id":"a43d5591.56ed18","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":300,"wires":[["cc02ac59.3372c"]]},{"id":"8dedc450.0d4a08","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":340,"wires":[["ea107285.20967"]]},{"id":"a4844f32.35c72","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\)\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":380,"wires":[["77c467bc.f001f8"]]},{"id":"c9e893ae.08c4b","type":"mqtt out","z":"701b8944.916b58","name":"Elektra verbruik laag tarief (DSMR v4.0)","topic":"/ESP_P1/T1","qos":"","retain":"","broker":"badcaf29.4c50e","x":580,"y":139,"wires":[]},{"id":"b05d2ce4.6e103","type":"mqtt out","z":"701b8944.916b58","name":"Elektra verbruik hoog tarief (DSMR v4.0)","topic":"/ESP_P1/T2","qos":"","retain":"","broker":"badcaf29.4c50e","x":580,"y":180,"wires":[]},{"id":"29d5618a.90cc1e","type":"mqtt out","z":"701b8944.916b58","name":"Elektra actueel verbruik (DSMR v4.0)","topic":"/ESP_P1/Actual","qos":"","retain":"","broker":"badcaf29.4c50e","x":570,"y":220,"wires":[]},{"id":"9957689f.adf378","type":"mqtt out","z":"701b8944.916b58","name":"Elektra teruglevering laag tarief (DSMR v4.0)","topic":"/ESP_P1/T1Retour","qos":"","retain":"","broker":"badcaf29.4c50e","x":590,"y":260,"wires":[]},{"id":"cc02ac59.3372c","type":"mqtt out","z":"701b8944.916b58","name":"Elektra teruglevering hoog tarief (DSMR v4.0)","topic":"/ESP_P1/T2Retour","qos":"","retain":"","broker":"badcaf29.4c50e","x":590,"y":300,"wires":[]},{"id":"ea107285.20967","type":"mqtt out","z":"701b8944.916b58","name":"Elektra actueel teruglevering (DSMR v4.0)","topic":"/ESP_P1/ActualRetour","qos":"","retain":"","broker":"badcaf29.4c50e","x":580,"y":340,"wires":[]},{"id":"77c467bc.f001f8","type":"mqtt out","z":"701b8944.916b58","name":"Gas (DSMR v4.0)","topic":"/ESP_P1/Gas","qos":"","retain":"","broker":"badcaf29.4c50e","x":510,"y":380,"wires":[]},{"id":"badcaf29.4c50e","type":"mqtt-broker","z":"","broker":"192.168.178.22","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

clauculo
Normal user
Posts: 2
Joined: 02 Feb 2018, 07:58

Re: ESPeasy and P1 smart meter MQTT

#6 Post by clauculo » 02 Feb 2018, 08:32

Tecumseh wrote:
17 Sep 2017, 19:50
After some trial and error attempts to use Node RED to parse the data I have had some success. I have pasted the Node-RED configuration I've created. As my knowledge for javascript is limited tips for improvements are most welcome.

Code: Select all

[{"id":"b233928e.ce6fc","type":"tcp in","z":"701b8944.916b58","name":"Node-RED Client","server":"client","host":"192.168.178.16","port":"8088","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"P1","base64":false,"x":100,"y":60,"wires":[["8d63c2a5.674b9"]]},{"id":"8d63c2a5.674b9","type":"function","z":"701b8944.916b58","name":"Trim","func":"msg.payload = msg.payload.trim();\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":60,"wires":[["1b090555.29792b"]]},{"id":"1b090555.29792b","type":"switch","z":"701b8944.916b58","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"1-0:1.8.1","vt":"str"},{"t":"cont","v":"1-0:1.8.2","vt":"str"},{"t":"cont","v":"1-0:1.7.0","vt":"str"},{"t":"cont","v":"1-0:2.8.1","vt":"str"},{"t":"cont","v":"1-0:2.8.2","vt":"str"},{"t":"cont","v":"1-0:2.7.0","vt":"str"},{"t":"cont","v":"0-1:24.2.1","vt":"str"},{"t":"else"}],"checkall":"true","outputs":8,"x":90,"y":260,"wires":[["a54ea4e4.1dcd88"],["ad0fa246.c824a"],["aa070718.aa29e8"],["73857243.28640c"],["a43d5591.56ed18"],["8dedc450.0d4a08"],["a4844f32.35c72"],["c3a5f168.e0645"]]},{"id":"c3a5f168.e0645","type":"debug","z":"701b8944.916b58","name":"Overig","active":false,"console":"false","complete":"payload","x":290,"y":420,"wires":[]},{"id":"d0a16e08.1086a","type":"comment","z":"701b8944.916b58","name":"DSMR v4.0","info":"1-0:1.8.1 = Elektra verbruik laag tarief (DSMR v4.0)\n1-0:1.8.2 = Elektra verbruik hoog tarief (DSMR v4.0)\n1-0:1.7.0 = Elektra actueel verbruik (DSMR v4.0)\n1-0:2.8.1 = Elektra teruglevering laag tarief (DSMR v4.0)\n1-0:2.8.2 = Elektra teruglevering hoog tarief (DSMR v4.0)\n1-0:2.7.0 = Elektra actueel teruglevering (DSMR v4.0)\n0-1:24.2.1 = Gas (DSMR v4.0)","x":530,"y":60,"wires":[]},{"id":"a54ea4e4.1dcd88","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":140,"wires":[["c9e893ae.08c4b"]]},{"id":"ad0fa246.c824a","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":180,"wires":[["b05d2ce4.6e103"]]},{"id":"aa070718.aa29e8","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":220,"wires":[["29d5618a.90cc1e"]]},{"id":"73857243.28640c","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":260,"wires":[["9957689f.adf378"]]},{"id":"a43d5591.56ed18","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":300,"wires":[["cc02ac59.3372c"]]},{"id":"8dedc450.0d4a08","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":340,"wires":[["ea107285.20967"]]},{"id":"a4844f32.35c72","type":"function","z":"701b8944.916b58","name":"parseFloat","func":"var regExp = /\\)\\((.*)\\*/;\nvar results = regExp.exec(msg.payload);\nmsg.payload = parseFloat(results[1]);\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":380,"wires":[["77c467bc.f001f8"]]},{"id":"c9e893ae.08c4b","type":"mqtt out","z":"701b8944.916b58","name":"Elektra verbruik laag tarief (DSMR v4.0)","topic":"/ESP_P1/T1","qos":"","retain":"","broker":"badcaf29.4c50e","x":580,"y":139,"wires":[]},{"id":"b05d2ce4.6e103","type":"mqtt out","z":"701b8944.916b58","name":"Elektra verbruik hoog tarief (DSMR v4.0)","topic":"/ESP_P1/T2","qos":"","retain":"","broker":"badcaf29.4c50e","x":580,"y":180,"wires":[]},{"id":"29d5618a.90cc1e","type":"mqtt out","z":"701b8944.916b58","name":"Elektra actueel verbruik (DSMR v4.0)","topic":"/ESP_P1/Actual","qos":"","retain":"","broker":"badcaf29.4c50e","x":570,"y":220,"wires":[]},{"id":"9957689f.adf378","type":"mqtt out","z":"701b8944.916b58","name":"Elektra teruglevering laag tarief (DSMR v4.0)","topic":"/ESP_P1/T1Retour","qos":"","retain":"","broker":"badcaf29.4c50e","x":590,"y":260,"wires":[]},{"id":"cc02ac59.3372c","type":"mqtt out","z":"701b8944.916b58","name":"Elektra teruglevering hoog tarief (DSMR v4.0)","topic":"/ESP_P1/T2Retour","qos":"","retain":"","broker":"badcaf29.4c50e","x":590,"y":300,"wires":[]},{"id":"ea107285.20967","type":"mqtt out","z":"701b8944.916b58","name":"Elektra actueel teruglevering (DSMR v4.0)","topic":"/ESP_P1/ActualRetour","qos":"","retain":"","broker":"badcaf29.4c50e","x":580,"y":340,"wires":[]},{"id":"77c467bc.f001f8","type":"mqtt out","z":"701b8944.916b58","name":"Gas (DSMR v4.0)","topic":"/ESP_P1/Gas","qos":"","retain":"","broker":"badcaf29.4c50e","x":510,"y":380,"wires":[]},{"id":"badcaf29.4c50e","type":"mqtt-broker","z":"","broker":"192.168.178.22","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
Looking good!
Can you explain what you did?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest