P1#Data not Published

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
sincze
Normal user
Posts: 43
Joined: 15 Jul 2016, 12:54

P1#Data not Published

#1 Post by sincze » 30 Mar 2024, 17:16

Build: ESP_Easy_mega_20240325_collection_C_ESP8266_4M1M Mar 25 2024

So I started some experimenting with the "Communication - Serial Server"
It acts as an interface between Domoticz and the P1 meter.

After reading through the forum I noticed the extended possibility to enable:

Code: Select all

Event Processing 'Generic'
This allows me to publish the RAW data to MQTT via the rule:

Code: Select all

on !Serial* do // Include * to process string values
  Publish,ESP_Easy/%sysname%/P1,%eventvalue%
endon
That worked nice, however when I try

Code: Select all

EventProcessing; "P1 Wifi Gateway"
and

Code: Select all

P1 #date event with message (true)
I am unable to publish the data.
However the EspEasy log shows:

Code: Select all

Smartmeter#Data=/CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240330165651W),0-0:96.1.1(4530303930303030373331343231333233),
So I thought the following rule should also do the trick:

Code: Select all

on !Smartmeter#Data* do
  logEntry,"Serial1"
  Publish,ESP_Easy/%sysname%/P1,%eventvalue%
endon
Even tried

Code: Select all

on Smartmeter#Data do
and

Code: Select all

on [Smartmeter#Data] do
but no data gets published.

What did I miss??

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: P1#Data not Published

#2 Post by Ath » 30 Mar 2024, 17:56

sincze wrote: 30 Mar 2024, 17:16 That worked nice, however when I try

Code: Select all

EventProcessing; "P1 Wifi Gateway"
and

Code: Select all

P1 #date event with message (true)
I am unable to publish the data.
However the EspEasy log shows:

Code: Select all

Smartmeter#Data=/CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240330165651W),0-0:96.1.1(4530303930303030373331343231333233),
So I thought the following rule should also do the trick:

Code: Select all

on !Smartmeter#Data* do
  logEntry,"Serial1"
  Publish,ESP_Easy/%sysname%/P1,%eventvalue%
endon
Even tried

Code: Select all

on Smartmeter#Data do
and

Code: Select all

on [Smartmeter#Data] do
but no data gets published.

What did I miss??
Handling P1 data is best done using P044, the P1 WiFi gateway. That's essentially the same as using P020 Serial Server (they share ~98% of the code), but P044 has some optimizations for handling P1 data, like a larger receive-buffer. Don't forget to set the RX Receive timeout at 2 or 3 msec, but you seem to have that covered ;)
When using an ESP8266, you may run out of memory (RAM) when receiving large messages like P1 data, so it may work better when running this on an ESP32-type unit.

%eventvalue% is an alias for %eventvalue1% for backward compatibility, so maybe it's not what you expected? To get all arguments, passed to the event handler, you should use %eventvalue0%

To have an event accepted with a non-numeric first argument like the P1 data, you will need to add an asterisk in the

Code: Select all

"On Smartmeter#Data* Do"
handler definition.
To see what's actually handled by the rule, you can add:

Code: Select all

LogEntry,'Data: %eventvalue0%'
/Ton (PayPal.me)

sincze
Normal user
Posts: 43
Joined: 15 Jul 2016, 12:54

Re: P1#Data not Published

#3 Post by sincze » 01 Apr 2024, 18:41

Ath wrote: 30 Mar 2024, 17:56 Handling P1 data is best done using P044, the P1 WiFi gateway. That's essentially the same as using P020 Serial Server (they share ~98% of the code), but P044 has some optimizations for handling P1 data, like a larger receive-buffer. Don't forget to set the RX Receive timeout at 2 or 3 msec, but you seem to have that covered ;)
When using an ESP8266, you may run out of memory (RAM) when receiving large messages like P1 data, so it may work better when running this on an ESP32-type unit.
Ah I did not go for the P044 as the info here states the following:
https://espeasy.readthedocs.io/en/lates ... /P044.html

Code: Select all

This plugin is now merged (back) into Communication - Serial Server where it initially was forked off from, with using some predefined settings.
So I guessed no to use that one anymore.
I can try your other suggestions ;-)

sincze
Normal user
Posts: 43
Joined: 15 Jul 2016, 12:54

Re: P1#Data not Published

#4 Post by sincze » 01 Apr 2024, 18:57

Ok with the help provided earlier this is the initial setup that works:

Code: Select all

on !Serial* do // Include * to process string values
//  logEntry,"Serial1"
  Publish,ESP_Easy/%sysname%/P1,%eventvalue%
endon
Provides the following data

Code: Select all

178599454: EVENT: !Serial#/CTA5ZIV-METER^^^^1-3:0.2.8(50)^^0-0:1.0.0(240401184851S)^^0-0:96.1.1(4530303930303030373331343231333233)^^1-0:1
178599474: ACT : Publish,ESP_Easy/Watermeter/P1,!Serial#/CTA5ZIV-METER^^^^1-3:0.2.8(50)^^0-0:1.0.0(240401184851S)^^0-0:96.1.1(45303039303
Modified the rules part and trying to publish:

Code: Select all

On Smartmeter#Data* Do"
  LogEntry,'Data: %eventvalue0%'
  Publish,ESP_Easy/%sysname%/P2,%eventvalue0%
endon

Code: Select all

178666864: Ser2Net: Client connected!
178666877: EVENT: Smartmeter#Client=1
178667010: EVENT: Smartmeter#Data=/CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240401184959S),0-0:96.1.1(4530303930303030373331343231333233),1-
178667023: ACT : '
178668116: EVENT: Smartmeter#Data=/CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240401185000S),0-0:96.1.1(4530303930303030373331343231333233),1-
178668283: ACT : '
Nothing seems to get published.

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: P1#Data not Published

#5 Post by Ath » 01 Apr 2024, 19:12

What's that character right after the "Do" ? Looks like that doesn't belong there
/Ton (PayPal.me)

sincze
Normal user
Posts: 43
Joined: 15 Jul 2016, 12:54

Re: P1#Data not Published

#6 Post by sincze » 01 Apr 2024, 19:59

Ath wrote: 01 Apr 2024, 19:12 What's that character right after the "Do" ? Looks like that doesn't belong there
Sometimes I feel a bit stupid :lol:

Code: Select all

On Smartmeter#Data* Do
  LogEntry,'Data: %eventvalue0%'
  Publish,ESP_Easy/%sysname%/P1,%eventvalue0%
endon
Result in the log:

Code: Select all

182691391: ACT : Publish,ESP_Easy/Watermeter/P1,/CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240401195703S),0-0:96.1.1(45303039303030303733313
182692464: EVENT: Smartmeter#Data=/CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240401195704S),0-0:96.1.1(4530303930303030373331343231333233),1-
182692479: ACT : LogEntry,'Data: /CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240401195704S),0-0:96.1.1(4530303930303030373331343231333233),1-
182692487: Data: /CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240401195704S),0-0:96.1.1(4530303930303030373331343231333233),1-0:1.8.1(003492.34
Mosquitto shows only: ESP_Easy/Watermeter/P1

Code: Select all

/CTA5ZIV-METER
The rest of the info seems not to be there at all.

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: P1#Data not Published

#7 Post by Ath » 01 Apr 2024, 20:20

Better use like this:

Code: Select all

 Publish,ESP_Easy/%sysname%/P1,'%eventvalue0%'
(adding quotes around the data part)

I assume the parser stumbles over the empty argument (double comma), and stops parsing the rest of the line, while it's supposed to also return the rest of the data. Wrapping in quotes avoids all that.
/Ton (PayPal.me)

sincze
Normal user
Posts: 43
Joined: 15 Jul 2016, 12:54

Re: P1#Data not Published

#8 Post by sincze » 01 Apr 2024, 20:30

Ath wrote: 01 Apr 2024, 20:20 Better use like this:

Code: Select all

 Publish,ESP_Easy/%sysname%/P1,'%eventvalue0%'
(adding quotes around the data part)

I assume the parser stumbles over the empty argument (double comma), and stops parsing the rest of the line, while it's supposed to also return the rest of the data. Wrapping in quotes avoids all that.
Djeez you are literary spoon feeding the solution :D to me.
It worked.
There is really a lot of unseen action going on in the background. :D

Code: Select all

/CTA5ZIV-METER,,1-3:0.2.8(50),0-0:1.0.0(240401202652S),0-0:96.1.1(4530303930303030373331343231333233),1-0:1.8.1(003493.095*kWh),1-0:1.8.2(001754.853*kWh),1-0:2.8.1(000295.133*kWh),1-0:2.8.2(000729.567*kWh),0-0:96.14.0(0001),1-0:1.7.0(02.607*kW),1-0:2.7.0(00.000*kW),0-0:96.7.21(00013),0-0:96.7.9(00010),1-0:99.97.0(4)(0-0:96.7.19)(230922112108S)(0000004157*s)(230918162050S)(0000000339*s)(230822142827S)(0000000214*s)(230801123219S)(0000002519*s),1-0:32.32.0(00000),1-0:52.32.0(00000),1-0:72.32.0(00000),1-0:32.36.0(00014),1-0:52.36.0(00009),1-0:72.36.0(00012),0-0:96.13.0(),1-0:32.7.0(236.0*V),1-0:52.7.0(237.0*V),1-0:72.7.0(235.0*V),1-0:31.7.0(001*A),1-0:51.7.0(001*A),1-0:71.7.0(009*A),1-0:21.7.0(00.085*kW),1-0:41.7.0(00.251*kW),1-0:61.7.0(02.274*kW),1-0:22.7.0(00.000*kW),1-0:42.7.0(00.000*kW),1-0:62.7.0(00.000*kW),0-1:24.1.0(003),0-1:96.1.0(4730303732303034323130343432323232),0-1:24.2.1(240401202500S)(00733.167*m3),!9D54,
But really I got confused by these 2 different ways of getting action out of the rules. They now both work but are slightly different. (of course not simultaneously)

Code: Select all

on !Serial* do // Include * to process string values
//  logEntry,"Serial1"
  Publish,ESP_Easy/%sysname%/P1,%eventvalue%
endon

On Smartmeter#Data* Do
  LogEntry,'Data: %eventvalue0%'
  Publish,ESP_Easy/%sysname%/P1,'%eventvalue0%'
endon

TD-er
Core team member
Posts: 8762
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P1#Data not Published

#9 Post by TD-er » 01 Apr 2024, 21:09

The !Serial* is a bit of legacy as the Serial Server plugin did send it out as a special kind of event which was one of the first kind of events supporting string like arguments.
Later we changed it but left this one in for compatibility reasons as there are setups out in the field using it and you don't want to break working setups.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests