Skip to content

Expand catalog of units and registers, fix some and use decimals#8

Merged
gertvdijk merged 11 commits intodevelopfrom
new-registers-and-units-pr-4
Apr 21, 2026
Merged

Expand catalog of units and registers, fix some and use decimals#8
gertvdijk merged 11 commits intodevelopfrom
new-registers-and-units-pr-4

Conversation

@gertvdijk
Copy link
Copy Markdown
Owner

@gertvdijk gertvdijk commented Apr 19, 2026

This is mostly cherry-picking @jktjkt's commits from PR #4 in a slightly different order and with some updated commit messages and code comments.

I would like to ask @jktjkt to review the state of this PR given my edits to their commits.

TODOs:

@gertvdijk gertvdijk mentioned this pull request Apr 19, 2026
Comment thread src/pykmp/constants.py
@@ -117,6 +117,12 @@
62: "days",
63: "RTC-Q",
64: "Datetime",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can also add:

  • 65: "imp/L", impulses per liter
  • 66: "L/imp", liters per impulse

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Thanks! I'll adopt it lowercase as other liters are denoted with lowercase-l, is that OK?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed

@jktjkt
Copy link
Copy Markdown
Contributor

jktjkt commented Apr 19, 2026

Re commit cd15365 and some bits in the commit message:

  • 259 is very likely the Q_p, aka the nominal flow,

This is indeed Q_p for V1. There's also reg. 260 which is Q_p for V2.

  • 400 is an educated guess, a one-decimal-digit precise T1-T2 difference

That's correct and documented by the vendor in another document (that I cannot share).

  • 675 is only present on our wireless M-Bus enabled Multical 303 which were
    procured with a transmission interval of 96 seconds that seems
    to match the register value.

I do not see this in the docs, but my original guess is as good as it was before.

You might also want to squash commit 8786735 in there (registers cfg no 3 and cfg no 4).

@gertvdijk gertvdijk force-pushed the new-registers-and-units-pr-4 branch from 6cdb0cb to 647aa45 Compare April 20, 2026 19:25
@gertvdijk
Copy link
Copy Markdown
Owner Author

I think I've incorporated all now. 😃

I would prefer to merge #7 first, then doing the remaining TODO on the changelog.

@gertvdijk gertvdijk force-pushed the new-registers-and-units-pr-4 branch from 647aa45 to 6aff223 Compare April 21, 2026 21:42
Copy link
Copy Markdown
Contributor

@jktjkt jktjkt left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Copy Markdown
Contributor

@jktjkt jktjkt left a comment

Choose a reason for hiding this comment

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

Ooops, I'm getting some error in the test suite, let me investigate. Sorry for noise.

@gertvdijk gertvdijk force-pushed the new-registers-and-units-pr-4 branch from 6aff223 to 2497571 Compare April 21, 2026 22:27
gertvdijk and others added 11 commits April 22, 2026 00:34
The vast majority of the vendor-provided documentation uses decimal numbers
as the primary format -- and so does this tool in its default output. I
only found a couple of documents which used hex numbers, and in these cases
they were always accompanied with the decimal equivalent. I saw no
instance of hexadecimal with no decimal equivalents.
"Kelvin degrees" is an ancient way to denote the Kelvin unit of
temperature. The unit name "degree kelvin" was changed to "kelvin" in
1967 (13th CGPM, Resolution 3).

See also: https://physics.nist.gov/cuu/pdf/sp330.pdf (page 34)

Co-Authored-By: Gert van Dijk <github@gertvandijk.nl>
Unit ID 21 is stated as W (watts) in the "58101758_B1_GB_02.2021" document
(Modbus register mapping, Modbus RTU, Modbus/KMP TCP/IP"). It also makes
sense, looking at the pattern of the order-of-magnitude scales in the table
of units.

The error appears to be coming from other KMP reader implementations:
- bsdphk/PyKamstrup@3ca8785
- esphome/esphome@64a47f8#diff-244b855ce21060b07df0fb916a2d2541e6814ca7312a5dc91c05935f3e076c15R70
This is speculative (I have no KMP-speaking electricity meter with an IEC
optical port), but given that the "kvar" is already defined, and looking at
the other units seeing a pattern of the order-of-magnitude scale, this is
very likely a typo.

See also the parent commit here for a similar unit scale error corrected.
IDs 85-90 come from the "58101758_B1_GB_02.2021" document (Modbus
register mapping, Modbus RTU, Modbus/KMP TCP/IP"). I have not seen them
in my meters, but given that all the other values match, I would say
there is a good chance that they are correct.
Some of these calculators support multiple flow meters, so let's identify
which "channel" this is using.
… 110

The datasheet has this information, so let's include it in the source code.
Almost all of these were cross-checked against a number of PDFs which I
found on the web. The exceptions are documented in the code:

- 259 & 260 are very likely the Q_p, aka the nominal flow, for V1 and V2
  respectively.
- 675 is only present on our wireless M-Bus enabled Multical 303 which
  were procured with a transmission interval of 96 seconds that seems to
  match the register value.
These were provided by Benny Lyne Amorsen and cross-checked against
Poul-Henning Kamp's bsdphk/PyKamstrup repository:
https://github.com/bsdphk/PyKamstrup/blob/f5692d29180024d9a59aa35a075f380ca8018276/kamstrup.py

References: #2
@gertvdijk gertvdijk force-pushed the new-registers-and-units-pr-4 branch from 2497571 to 6e77910 Compare April 21, 2026 22:35
@gertvdijk
Copy link
Copy Markdown
Owner Author

Ooops, I'm getting some error in the test suite, let me investigate. Sorry for noise.

So that was in #9 right? ✅

Comment thread src/pykmp/constants.py
@@ -117,6 +117,12 @@
62: "days",
63: "RTC-Q",
64: "Datetime",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed

@gertvdijk gertvdijk merged commit afb2097 into develop Apr 21, 2026
@gertvdijk gertvdijk deleted the new-registers-and-units-pr-4 branch April 21, 2026 22:44
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.

2 participants