Work-around for meters that publish W instead of kW #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue
While specifications tell us that a smart meter ought to publish its values as floating point values in kW, there are meters out there that publish an integer value in W. This results in error messages like these:
The solution
This PR modifies the parser, to allow both a float and an integer, as long as the unit as published by the meter matches those types. So based on the example from above, meters can now publish either of:
1-0:1.8.0(000441874*Wh)
Any other combination of data type and unit will still result in an
Invalid unit
, meaning that these two are not accepted by the parser:1-0:1.8.0(000441874*kWh)
1-0:1.8.0(00044.1874*Wh)
The solution is backward compatible, and the change has been tested against a standard smart meter and an affected smart meter (a Sagemom smart meter from Austria).