-
Notifications
You must be signed in to change notification settings - Fork 62
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
Generic SML based power meters support #146
Generic SML based power meters support #146
Conversation
…king OBIS 16.7.1 for power (using mod. SML Parser lib. by olliiiver)
For my undesrtanding, is it for IR Power Merers, like "Volkszähler"? In general, I'would switch UART-based-PowerMeters, like SML and SDM to software serial. Maybe Victron 19200bps is also possible with SW-Serial. More than one Victron is also not really possible because of UARTs |
I want to extend viltron interface to use more than one charger and that hard and software serial could be used. |
@berni2288 which power meter ID are you using fot HTTP(S)? something like that, so we can add more PowerMeters in beetween. |
I've taken 3, but I don't really care :) maybe change this to an enum so this can be changed easily at one place. |
@Adminius Exactly. It's aimed for powermeters that fan out their data using SML via 9600 8N1 serial - IR signal. Regarding the usage of the SoftwareSerial: Yes my first intention was also to use this, since only rx is required and the baudrate is low. Unfortunately I got unexpected byte errors from time to time in real operation when hoymiles module was active. But the main reason to go with HardwareSerial for now was that since the update of the new compile settings the EspSoftwareSerial doesn't compile anymore if 'gnu++11' is disabled via 'build_unflags' in platformio.ini. |
yeah... this is what I already found with SDM integration... |
Thanks for the hint!, Just tried that and it compiles now again. But the unexpected byte problem remains a thing. |
I see, SML in the list... D0 would be next possiblity. |
The switch to software serial usage is complete. I set its buffer sizes to a value that should make sense. Which in turn reduced the observed SML unexpected state significantly. |
@qubeck look at my comments about |
@Adminius sorry but I can't see any, at least there are none visible to me. Strange... |
you don't need |
That's why I changes also "float PowerMeterClass::getPowerTotal()" to only return "_powerMeterTotalPower" And all of the powers are applied source individually in the loop. That way it's much more cleaner. In SML 16.7.0 case there are also no phase specific powers so putting it in to one of the phase powers to get responded by getPowerTotal() would be a little bit confusing. |
PowerMeter is from me and I had it this way at the beginning (that's why _powerMeterTotalPower is there). |
I see your point, well may be in that case an alternative would be something like: And total power would be only applied by meter sources that do not have individual readings. |
If you have a real "zero export" ("Nulleinspeisung"), _powerMeterTotalPower = 0 and also _powerMeterTotalPower < 0 are valid values... |
Yes, of course... So we need to flag that case by something like: Also I see that the mqtt subscriptions there are also source specific and need to be turned of in that case. |
kW theoretically only... never heard that Power meters in home applications usung kW But you also see why I'm using first power 1 und other 2 are 0 in single phase SDM implementation. Easiest solution, without flags and so on ;) |
Well since it gets also published via mqtt it can become confusing eventually. Especially in the case where powermeeters could have pos. and neg. readings for each phase but do not present that power transparently. |
Well, mqtt publishes power1, power2, power3 and powertotal. |
…ither the sum of phase powers or explicit total power provided by meter
9b58c28
to
6f84c31
Compare
Should not be power L1 ...L3? Sure they doesn't have to be... but the calls to the SDM lib for the _powerMeter...Power are: So they are implicit phase power readings. But yeah that can be any power reading of course and is physically determined eventually. In the end they are added up like anyone would do with phase power readings... |
In case of SDM this are 3 phases=3 power sources. |
I simplified the code to make it more smoother to integrate into the existing module. Btw. I observed some interesting behavior at trying to configure zero export with the power limiter. It appears that the inverter internally distributes the applied power limit across all DC channels. e.g. with only 1x producing DC channel (in my case @ HM-600) this results in the power limit gets applied with long delay over time, since only a fraction of the requested power limit becomes active on the actual producing DC channel when power limiter kicks in. This can be improved by taking the number of actually producing DC channels into account to increase the applied power limit artificially. Just saying... I'll experiment with a slight modification to the power limiter as soon the weather becomes better. But this is of course a topic for an other discussion... |
It would be interesting if this PR fixes your problem: #154 |
Hi, https://tasmota.github.io/docs/Smart-Meter-Interface/ Finally, since #153, the powermeterclass retrieves the values from tasmota via http(s). |
|
d1640f8
to
d06196a
Compare
I think now would be the best time for a review and merge before it diverge any further... |
src/PowerMeter.cpp
Outdated
@@ -15,6 +15,15 @@ PowerMeterClass PowerMeter; | |||
|
|||
SDM sdm(Serial2, 9600, NOT_A_PIN, SERIAL_8N1, SDM_RX_PIN, SDM_TX_PIN); | |||
|
|||
#define USE_SW_SERIAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder... what's the point of this constant that can't be overriden via build parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decision about using the HW/SW serial wasn't made back then. So I left the option. But yeah I will remove it.
include/PowerMeter.h
Outdated
float _powerMeterImport = 0.0; | ||
float _powerMeterExport = 0.0; | ||
|
||
bool _powerMeterOnlyTotalPowerAvailable = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fully sure if that's a good idea. It's inconsistent behavior with the other Power meters where you currently can only set the power per phase.
Also I don't understand why all member variables are starting with _powerMeter
? PowerMeter is already part of the class name.
I guess we will need some refactoring of the Power meters, it's becoming a bit messy already (not your fault).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I introduced that flag because SML power reading obtained from OBIS 16.7.0 list can not be related to any specific phase. It's the signed sum of all and I didn't want to confuse anything an put it into one of the phases.
Especially, because that powers are getting published...
@@ -215,10 +215,11 @@ export default defineComponent({ | |||
dataLoading: true, | |||
powerMeterConfigList: {} as PowerMeterConfig, | |||
powerMeterSourceList: [ | |||
{ key: 3, value: this.$t('powermeteradmin.typeHTTP') }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might not've looked aesthetic in the code, but it was put on top on purpose because typeHTTP is probably the most used one :) But it's ok, we can also order it by number if you would like to.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns. |
Add support for generic reading of SML based power meters by taking OBIS 1.8.0 & 2.8.0 lists for import & export of energy and OBIS 16.7.0 list for signed power value.
To not conflict with any upcoming extensions of the power meter class the power meter source was set to 99 for this extension.