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

Vzlogger struggles when Meter shifts from 3 byte to 2 byte in SML #533

Open
fhwe71 opened this issue Jul 13, 2022 · 6 comments
Open

Vzlogger struggles when Meter shifts from 3 byte to 2 byte in SML #533

fhwe71 opened this issue Jul 13, 2022 · 6 comments

Comments

@fhwe71
Copy link

fhwe71 commented Jul 13, 2022

I have a DZG meter DWSB20.2TH to measure my power consumption and photovoltaic delivery.

Normally the meter sends 3 bytes with a factor 10^-2, e.g. 54 fe 9a 84 -> (ff ff ff - fe 9a 84 + 1)*0,01 = -915,15 Watt consumption, thus 915,15 Watt are fed into the grid.

When the power consumption goes towards zero, the meter shifts to 2 bytes.
Example 53 80 f7 -> ( ffff-80 f7+1)*0,01 = -325,21 Watt consumption, 325,21W are delivered.

Nevertheless vzlogger assumes it's still 3 byte, and as the value is smaller than 7fffff, it calculates (0x80f7)*0,01 = 330,15 Watt consumption - which is a difference of more than 650 Watt!

This happens in the morning and evening when consumption is around zero. In the night, when it's really less than zero or during day delivery is high, 3 bytes are sent and everything is fine. Photos you can find here: https://www.photovoltaikforum.com/thread/177445-fehler-smart-meter-oder-wechselrichterproblem/?postID=2688274#post2690322

I wonder whether this is specific to DZG meters or happens with all meters. Nevertheless vzlogger is quite useless for me like that.
Can this be corrected?

@r00t-
Copy link
Contributor

r00t- commented Jul 14, 2022

without having looked at the code, i wonder if this is a vzlogger or a libsml bug.
can you please dump/attach raw sml telegrams of both cases? (ideally submit them here: https://github.com/devZer0/libsml-testing/blob/master/README.md )
can you also test if examples/sml_server from libsml processes the telegrams correctly?

@fhwe71
Copy link
Author

fhwe71 commented Jul 14, 2022

Done. I am no Github expert, hope everything was uploaded correctly. I processed the dumps with sml_server and the same effect occurs. Everything fine when 3 bytes are sent, wrong interpretation with 2 bytes.
I think the meter does everything correctly, it uses type "5" for signed bytes + correct length. Anyway smllib recognizes the structure and length correctly, just it does not pass the information of 2 byte length to the conversion routine.

@r00t-
Copy link
Contributor

r00t- commented Dec 25, 2022

@fhwe71:
i'n not sure if i'm not missing something here,
but i don't see how the issue could possibly be in vzlogger instead of libsml.
all vzlogger does with sml readings is pass them to sml_value_to_double(), and then use the converted value returned by that:
https://github.com/volkszaehler/vzlogger/blob/27eb8d1566ec493d9cf64d2b53676c846ebb6e35/src/protocols/MeterSML.cpp
which appears to do the conversion (or just return a converted value generated when parsing, i'm not so deep into the libsml code):
https://github.com/volkszaehler/libsml/blob/559ca1e3ff8de7645fc4372f632e42b64cec780f/sml/src/sml_value.c
the 53 and 54 case are handled in sml_value_to_double(), so if anything, the bug must be in libsml?

@r00t-
Copy link
Contributor

r00t- commented Dec 25, 2022

are these the expected values or wrong ones?

[libsml]$ ./examples/sml_server - <../vzlogger/dzg_dwsb20_2th_2byte.bin | grep 16.7
1-0:16.7.0*255#344.72#W
1-0:16.7.0*255#346.08#W
1-0:16.7.0*255#349.54#W
1-0:16.7.0*255#349.00#W
1-0:16.7.0*255#352.71#W
1-0:16.7.0*255#353.43#W
1-0:16.7.0*255#353.59#W
1-0:16.7.0*255#344.48#W
1-0:16.7.0*255#353.41#W
1-0:16.7.0*255#345.07#W
1-0:16.7.0*255#343.57#W
1-0:16.7.0*255#347.96#W
1-0:16.7.0*255#349.92#W
1-0:16.7.0*255#346.95#W
1-0:16.7.0*255#348.48#W

@fhwe71
Copy link
Author

fhwe71 commented Dec 26, 2022

Thanks for asking. I expect it's a libsml problem then. Currently I only can tell what I reported above was what I measured and it was incorrect. I will do a check with libsml in January, currently my data and equipment are not available.

@jmberg
Copy link

jmberg commented Nov 15, 2023

Have you guys seen this? volkszaehler/libsml#132

jmberg added a commit to jmberg/libsml that referenced this issue Nov 17, 2023
In volkszaehler#132 and volkszaehler/vzlogger#533 it was reported that there
are DZG meters that fall into the range currently deemed broken
(all DZG meters with serial numbers before 6000 0000), but aren't
actually broken. The reason for this seemed to be that they're a
different type than mine that was broken.

Further inquiry with DZG revealed that indeed only DVS74 meters
are affected by the encoding issue, and then _those_ only for
serial numbers before 6000 0000. They also said that (currently)
the serial number ranges
 - 4200 0000 to 4899 9999, and
 - 5500 0000 to 5899 9999
are reserved for DVS74 meters.

As such, make the workaround detection more specific, and we no
longer need to have the check for 6000 0000 either, just need to
have a list of affected ranges. To achieve that, refactor the
code into a separate function that actually decodes the serial
number to an integer, so we can make the comparison more easily
and have the list of affected numbers more clearly in the code.

This should fix volkszaehler#132 since the serial number there starts with
4005, so it's clearly not in the affected ranges, as explained
by my contact at DZG. For volkszaehler/vzlogger#533 I don't have
the serial number, but it's the same type of meter as in volkszaehler#132.
jmberg added a commit to jmberg/libsml that referenced this issue Nov 27, 2023
In volkszaehler#132 and volkszaehler/vzlogger#533 it was reported that there
are DZG meters that fall into the range currently deemed broken
(all DZG meters with serial numbers before 6000 0000), but aren't
actually broken. The reason for this seemed to be that they're a
different type than mine that was broken.

Further inquiry with DZG revealed that indeed only DVS74 meters
are affected by the encoding issue, and then _those_ only for
serial numbers before 6000 0000. They also said that (currently)
the serial number ranges
 - 4200 0000 to 4899 9999, and
 - 5500 0000 to 5899 9999
are reserved for DVS74 meters.

As such, make the workaround detection more specific, and we no
longer need to have the check for 6000 0000 either, just need to
have a list of affected ranges. To achieve that, refactor the
code into a separate function that actually decodes the serial
number to an integer, so we can make the comparison more easily
and have the list of affected numbers more clearly in the code.

This should fix volkszaehler#132 since the serial number there starts with
4005, so it's clearly not in the affected ranges, as explained
by my contact at DZG. For volkszaehler/vzlogger#533 I don't have
the serial number, but it's the same type of meter as in volkszaehler#132.
jmberg added a commit to jmberg/libsml that referenced this issue Dec 11, 2023
In volkszaehler#132 and volkszaehler/vzlogger#533 it was reported that there
are DZG meters that fall into the range currently deemed broken
(all DZG meters with serial numbers before 6000 0000), but aren't
actually broken. The reason for this seemed to be that they're a
different type than mine that was broken.

Further inquiry with DZG revealed that indeed only DVS74 meters
are affected by the encoding issue, and then _those_ only for
serial numbers before 6000 0000. They also said that (currently)
the serial number ranges
 - 4200 0000 to 4899 9999, and
 - 5500 0000 to 5899 9999
are reserved for DVS74 meters.

As such, make the workaround detection more specific, and we no
longer need to have the check for 6000 0000 either, just need to
have a list of affected ranges. To achieve that, refactor the
code into a separate function that actually decodes the serial
number to an integer, so we can make the comparison more easily
and have the list of affected numbers more clearly in the code.

This should fix volkszaehler#132 since the serial number there starts with
4005, so it's clearly not in the affected ranges, as explained
by my contact at DZG. For volkszaehler/vzlogger#533 I don't have
the serial number, but it's the same type of meter as in volkszaehler#132.
r00t- pushed a commit to volkszaehler/libsml that referenced this issue Dec 11, 2023
In #132 and volkszaehler/vzlogger#533 it was reported that there
are DZG meters that fall into the range currently deemed broken
(all DZG meters with serial numbers before 6000 0000), but aren't
actually broken. The reason for this seemed to be that they're a
different type than mine that was broken.

Further inquiry with DZG revealed that indeed only DVS74 meters
are affected by the encoding issue, and then _those_ only for
serial numbers before 6000 0000. They also said that (currently)
the serial number ranges
 - 4200 0000 to 4899 9999, and
 - 5500 0000 to 5899 9999
are reserved for DVS74 meters.

As such, make the workaround detection more specific, and we no
longer need to have the check for 6000 0000 either, just need to
have a list of affected ranges. To achieve that, refactor the
code into a separate function that actually decodes the serial
number to an integer, so we can make the comparison more easily
and have the list of affected numbers more clearly in the code.

This should fix #132 since the serial number there starts with
4005, so it's clearly not in the affected ranges, as explained
by my contact at DZG. For volkszaehler/vzlogger#533 I don't have
the serial number, but it's the same type of meter as in #132.
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

No branches or pull requests

3 participants