Skip to content

DALI 306 - #158

Open
markus-becker-tridonic-com wants to merge 3 commits into
sde1000:masterfrom
tridonic-com:306
Open

markus-becker-tridonic-com wants to merge 3 commits into
sde1000:masterfrom
tridonic-com:306

Conversation

@markus-becker-tridonic-com

Copy link
Copy Markdown

Add IEC 62386-306 general sensor support

Summary

Adds support for IEC 62386-306 general sensors (instance type 6): the command and event classes, the measurement-metadata queries (resolution, magnitude, unit, quantity, signedness), and the Annex A enumerations for unit of measurement and quantity name — with tests.

What's included

  • General sensor support — GeneralSensorEvent plus the Part 306 measurement-variable queries and the UnitOfMeasurement / QuantityName enumerations from Annex A, Tables A.1 and A.2.
  • Vendor-extension unit codes 55 and 56 — Table A.1 ends at 53 (parts per million), but real hardware (Tridonic sonuSense) reports codes beyond that: 55 for A-weighted sound pressure level (dB(A)) and 56 for a manufacturer-defined probability instance. These are decoded rather than surfaced as unknown values, and are clearly marked in-code as non-306 extensions so a maintainer can drop them if upstream prefers to keep the enum strictly standard.

Testing

python3 -m pytest dali/tests/ — 114 passed, including the general-sensor decoding tests.

Note for reviewers

The second commit (vendor unit codes 55/56) is intentionally kept separate from the standards-compliant support so it can be dropped independently if you'd rather not carry non-standard vendor codes in the core enum.

The IEC 62386-306 Annex A, Table A.1 unit-of-measurement list ends at
53 (parts per million). Real hardware (Lunatone sonuSense) reports unit
codes beyond that: 55 for A-weighted sound pressure level and 56 for a
manufacturer-defined probability instance. Decode them instead of
surfacing them as unknown values, clearly marked as non-306 extensions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

class QueryMeasurementVariable(general._StandardInstanceCommand):
"""Query a Part 306 measurement variable selected by DTR0."""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

If sending this command increments DTR0, it would be a good idea to mention it in the command description here in addition to mentioning it in the docstring for the MeasurementVariable enum.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 9da4969. 01a5544 should be dropped, instead:

class UnitOfMeasurement(IntEnum):
    # ...
    # Clarifications and Recommendations for IEC 62386:
    DECIBEL_A = 54

class QuantityName(IntEnum):
    """Standard quantity-name values from Part 306 Annex A, Table A.2."""
    # ...
    # Clarifications and Recommendations for IEC 62386:
    GENERAL_PURPOSE_COUNTER = 59
    PEOPLE_COUNTER = 60

Document the DTR0 auto-increment behavior on the command itself, not
only on the MeasurementVariable enum, so callers see it where they issue
the query.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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