Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Modbus Sunspec compatibility to opendtu-onbattery #1150

Open
wants to merge 67 commits into
base: development
Choose a base branch
from

Conversation

AloisKlingler
Copy link

@AloisKlingler AloisKlingler commented Aug 3, 2024

this implementation is (maybe only partially) modbus-sunspec compatibility to simulate a sunspec energy-meter.

to have calculation (especially self-consumption) correct for e.g. fronius solar web you need to either place a 300€ fronius smart meter before each "foreign" inverter.

With this PR it is possible to configure OpenDTU with it's IP-address as a "Smartmeter" on Fronius Gen24 or Fronius Symo inverter. so the Fronius Inverter is able to poll current production and overall production continuously like a from a real fronius-smartmeter.

necessary configuration on OpenDTU:
image

configuration on an Gen24 Inverter:
image

visualisation on an Gen24 inverter:
image

visualisation of the additional "Smartmeter" in Fronius Solarweb as "Additional AC Source":
image

visualisation of the "Smartmeter" data in Solarweb is available as common curve like other inverters are:
image

for my OpenDTU (and also some other users of photovoltaikforum.com) this implementation is running now over a year (more or less) flawless.

to the PR: the tree conflicting files webapp_dist/* need to be resolved on merge. other conflicts I could solve.

ArekKubacki and others added 30 commits February 13, 2023 10:42
This reverts commit 5617240ce1fb15a3796d1ed558cc89f9ba72d8d5.
… "Total Power" and "Total Yield" into registers.
prevent sending 0 as "e_energy_exported" to avoid peaks and gaps in solarweb statistic
@AloisKlingler AloisKlingler marked this pull request as draft August 4, 2024 07:48
@AloisKlingler AloisKlingler marked this pull request as ready for review August 4, 2024 07:49
@AloisKlingler AloisKlingler marked this pull request as draft August 4, 2024 07:49
@AloisKlingler AloisKlingler marked this pull request as ready for review August 4, 2024 08:12
@spcqike
Copy link

spcqike commented Aug 5, 2024

thanks for your effort.

another thing, it would be good, if your changes would be based on helgeerbe:development or :master, too.

right now, your changes are based on a fork of the upstream project, which makes it difficult to compare or include as there may be many more changes than you actually want to add.

On the other hand, it is now only "+278/-3", which is much less than the previous "+3,652/-2,191". So I think the developer can work with that.

@AloisKlingler
Copy link
Author

thanks for your effort.

another thing, it would be good, if your changes would be based on helgeerbe:development or :master, too.

right now, your changes are based on a fork of the upstream project, which makes it difficult to compare or include as there may be many more changes than you actually want to add.

On the other hand, it is now only "+278/-3", which is much less than the previous "+3,652/-2,191". So I think the developer can work with that.

I am sorry for the confusion
I recognized yesterday that the implementation is already a at least SunSpec meter compatible implementation.
It looks like (at least) fronius inverters then only have additional checks for e.g. vendor to allow them beeing configured.

In a yet (in my repository) not commited change I created configuration for the necessary sunspec fields so it may be compatible with other inverters which do the same.

I will update this PR as soon as I have tested all the changes well enough.

@AloisKlingler AloisKlingler marked this pull request as draft August 6, 2024 06:20
Alois Klingler added 2 commits August 6, 2024 15:18
add configuration for elements to equip with custom vendor strings.
@AloisKlingler AloisKlingler changed the title add fronius smartmeter simulation to opendtu-onbattery add Modbus Sunspec compatibility to opendtu-onbattery Aug 7, 2024
@AloisKlingler AloisKlingler marked this pull request as ready for review August 7, 2024 08:45
@AndreasBoehm
Copy link
Member

AndreasBoehm commented Aug 21, 2024

There are still a lot of unrelated changes, please make sure that you base your branch off of the OpenDTU-OnBattery development branch.

to the PR: the tree conflicting files webapp_dist/* need to be resolved on merge. other conflicts I could solve.

Please do not commit any file within webapp_dist/. This is done by the upstream project OpenDTU but within the OnBattery repo we don't do that, not sure why but i can imagine that its because of the conflicts that would arise constantly.

@@ -76,6 +76,16 @@ struct CONFIG_T {
bool Enabled;
} Mdns;

struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add bool verboseLogging to your struct and use that to enable/disable logging within your Modbus module instead of commenting the logging lines.

@@ -45,6 +45,7 @@ lib_deps =
nrf24/RF24 @ 1.4.9
olikraus/U8g2 @ 2.35.19
buelowp/sunset @ 1.1.7
https://github.com/emelianov/modbus-esp8266#master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we point to a specific commit or release-tag instead of a branch?
This might break builds at any point in the future without us knowing whats going on.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently not, as there is a change which is most probably needed in master only:
emelianov/modbus-esp8266#292

as soon as there is a 4.1.2 (or whatever) released I think this one could be used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you specific the commit hash with #a5872af7250e03e9a5cd578366b0c2cdc097fcc9 instead of #master you can make sure that the dependency won't get updated randomly with the next push to master

Comment on lines +212 to +223
// mb.Hreg(0x9cbb, 0);
// mb.Hreg(0x9cbc, 0);
// mb.Hreg(0x9cbd, 0);
// mb.Hreg(0x9cbe, 0);
// mb.Hreg(0x9cbf, 0);
// mb.Hreg(0x9cc0, 0);
// value = (inv->Statistics()->getChannelFieldValue(TYPE_AC, CH0, FLD_YT)*1000); //done above already!
// if (value > _lasttotal) {
// _lasttotal = value;
// mb.Hreg(0x9cc1, hexbytes[1]); //done above already!
// mb.Hreg(0x9cc2, hexbytes[0]); //done above already!
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented lines if they are not needed


ModbusDtuClass ModbusDtu;

ModbusDtuClass::ModbusDtuClass()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense if we call it ModbusSunspec or SunspecModbus to explain what this is actually doing?

Do you have any documentation about the protocol that youa re implementing here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this implementation is (maybe only partially) modbus-sunspec compatibility to simulate a sunspec energy-meter.

as far as I could google, this should match to "sunspec meter" registers in float mode.
I could not check if it is the complete protocol or only partial.
at least, if I check against fronius documentation, it is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants