Add two fields in Output Configuration plugin P102_PZEM004Tv3

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
pp1wvc
Normal user
Posts: 39
Joined: 06 Jan 2023, 12:02
Location: Brazil

Add two fields in Output Configuration plugin P102_PZEM004Tv3

#1 Post by pp1wvc » 18 Sep 2023, 01:52

I have the P102_PZEM004Tv3 plugin working perfectly. But I need all six fields available and the plugin only offers four Output Configuration per device.
Question:
What is the reason for not making all Output Configuration fields available in the plugin?
Would just adding two more fields in _P102_PZEM004Tv3.ino ( # define P102_QUERY5) and (# define P102_QUERY6) for example solve the problem?
Is there a way to configure unavailable fields in rules and forward them through the controller? In my case I use zabbix.
Attachments
teste.jpg
teste.jpg (141.18 KiB) Viewed 1504 times

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

Re: Add two fields in Output Configuration plugin P102_PZEM004Tv3

#2 Post by Ath » 18 Sep 2023, 09:02

pp1wvc wrote: 18 Sep 2023, 01:52 I have the P102_PZEM004Tv3 plugin working perfectly. But I need all six fields available and the plugin only offers four Output Configuration per device.
You can add another task with that device and configure the other values, they will be sent separately to Zabbix.
pp1wvc wrote: 18 Sep 2023, 01:52 Question:
What is the reason for not making all Output Configuration fields available in the plugin?
Would just adding two more fields in _P102_PZEM004Tv3.ino ( # define P102_QUERY5) and (# define P102_QUERY6) for example solve the problem?
That will overwrite the first 2 values of the next task, and when configured as the last task, possibly cause crashes because it accesses memory it isn't supposed to access.
And please keep in mind that some devices have 100+ values to pick from...
pp1wvc wrote: 18 Sep 2023, 01:52 Is there a way to configure unavailable fields in rules and forward them through the controller? In my case I use zabbix.
Currently it's not possible to retrieve not-configured values from this plugin, but you can add that as a feature request on Github.
Sending to a controller (or any external server/service) can be done from rules.
/Ton (PayPal.me)

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

Re: Add two fields in Output Configuration plugin P102_PZEM004Tv3

#3 Post by TD-er » 18 Sep 2023, 09:08

The main reason we can't just add more task values is the way how settings are stored.
If you need to increase the number of task values, you also need to change the settings structure.
This will render it completely incompatible with existing settings and also a lot of code needs to be checked to see if we use the same define in all places.
Also some structs have their bits packed really tight and I'm 100% sure that wherever that's being packed is not dynamically updated when the define for number of task values is changed.

So changing the number of task values is not as simple as just changing a define.

However for some plugins we have added some extra options to access other registers too.
For example the Eastron plugin allows multiple instances of the same plugin and being configured for the same serial port and modbus address. This way you can access other registers too. (The SDM630 has about 100 registers with data)

For other plugins, which get all the available sample data anyway without asking, like GPS and PMSx003, we have added "virtual" task values.
So for example if you only have latitude/longitude/speed/altitude configured, you can still access the other values like [gps#hdop] (assuming your task is called "gps")

You could test to see if the PZEM004 plugin already has been updated to have multiple instances of the same plugin, like on the Eastron.
If not, then I guess that would by far be the best option.
Problem with Modbus devices is that you actively need to query data. So you can't "fetch all and pick whatever you like" as that would waste quite a lot of resources.

pp1wvc
Normal user
Posts: 39
Joined: 06 Jan 2023, 12:02
Location: Brazil

Re: Add two fields in Output Configuration plugin P102_PZEM004Tv3

#4 Post by pp1wvc » 18 Sep 2023, 12:03

Configured and working perfectly this way. Thank you very much for the answers. :D
Attachments
config_alt.jpg
config_alt.jpg (258.29 KiB) Viewed 1476 times

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests