Skip to content

Read the device types of gear that does not report them - #174

Open
huetti79 wants to merge 4 commits into
sde1000:masterfrom
tridonic-com:pr-device-types
Open

huetti79 wants to merge 4 commits into
sde1000:masterfrom
tridonic-com:pr-device-types

Conversation

@huetti79

Copy link
Copy Markdown

PR 1 — python-dali: read the device types of gear that does not report them

Open at: https://github.com/tridonic-com/python-dali/pull/new/pr-device-types
Base: sde1000/python-dali:master ← tridonic-com:pr-device-types
Scope: 1 commit, 4 files, +150 / −6 · independent of the other two python-dali PRs


Split out of #171 as requested.

The problem

A DALI gateway that emulates control gear answers 254 to QUERY DEVICE TYPE
while implementing device type 0. QueryDeviceTypes took that as "no device
type" and returned an empty list, so the gear's device type went unseen.

That meaning only arrives with IEC 62386-102:2014. Annex B, Table B.1 of the
2009 edition
— the edition this gear reports — reserves 128 to 254 for control
devices, and gives control gear no way to say it has no device type at all. So
254 from such gear says nothing about what it implements.

Evidence from the device

Lunatone DALI-2 USB PS (art. 24138246), gateway-emulated control gear at short
address 0:

Query Answer
QueryVersionNumber 1 — part 102 edition 1
QueryDeviceType (×3) 254, consistently
QueryNextDeviceType no answer
EnableDeviceType(0) + QueryExtendedVersionNumber 1
EnableDeviceType(1…15) + QueryExtendedVersionNumber no answer
QueryExtendedVersionNumber with no prefix no answer

The last row is the control: the gear does honour EnableDeviceType, so the
single answer at device type 0 is the Annex A.4 signature rather than an
artefact of the gear answering everything.

Other corroborating traits of this unit: its GTIN fails its own check digit
(9005203800853 → computes 4, reads 3), it does not answer QUERY POWER FAILURE,
QUERY LAMP FAILURE, QUERY LAMP POWER ON, QUERY CONTROL GEAR FAILURE or
QUERY RESET STATE although part 102 requires them, and it quantises DAPC
(128 reads back as 126). It is emulating, not implementing.

The change

QueryDeviceTypes falls back to the Annex A.4 probe in two cases:

  • gear answering 254, because that answer is ambiguous across editions
  • gear answering MASK without implementing QueryNextDeviceType to enumerate
    with, which previously raised DALISequenceError for gear behaving exactly as
    its edition of the standard says

Gear that genuinely has no device type answers none of the probes and is still
reported as having none, so the 254-means-none reading is preserved wherever
it is true.

Also fixes the ascending-order check on QueryNextDeviceType answers: it
compared each answer against 0 rather than against the previous answer, so a
first answer of 0 was rejected and the order went unchecked after that.

On the probe and EnableDeviceType

The probe yields EnableDeviceType(n) explicitly and then the plain
dali.gear.general.QueryExtendedVersionNumber, whose devicetype is 0, so the
driver adds no prefix of its own and the explicit one stands. This is
deliberate: Annex A.4 asks about device types chosen at run time, including the
five (2, 3, 7, 9, 10) that have no module of their own, so there is no
per-device-type command class to hang devicetype off. It is not a reinvention
of the driver's own EnableDeviceType handling (#161).

Testing

  • pytest dali/ — 137 passed; the three new tests fail without the change
  • mypy --strict dali/ — clean, 45 files
  • flake8 dali — 0
  • Verified end to end on the hardware above: QueryDeviceTypes returns []
    before and [0] after

🤖 Generated with Claude Code

Upstream PR coordination — DT0 / EnableDeviceType(0) / firmware transfer

Replaces sde1000/python-dali#171 and sde1000/dali-drivers#8, both of which
bundled independent features. Five PRs, each standing alone.

The five

# Repo Branch Depends on Tests
1 python-dali pr-device-types — 137
2 python-dali pr-enable-device-type-0 — 133
3 python-dali pr-firmware — 170
4 dali-drivers dd-enable-device-type-0 PR 2 released 64
5 dali-drivers dd-32bit-frames PR 3 released 80

All five: mypy --strict clean, flake8 0, working tree clean, rebased onto
current upstream (python-dali e2dee11, dali-drivers abd1297 / 1.0a4).

The three python-dali PRs are mutually independent and can be reviewed, merged
or rejected in any order. The two dali-drivers PRs are independent of each
other, but each needs its python-dali counterpart in a release, because
install_requires has to name it.

PR 2 (python-dali) ──released──> PR 4 (dali-drivers)
PR 3 (python-dali) ──released──> PR 5 (dali-drivers)
PR 1 (python-dali)  — standalone

Why PR 4 must not jump the queue

The drivers decide whether to prefix by testing cmd.devicetype. PR 2 changes
the "no prefix" value from 0 to None. Either half alone is broken:

  • old driver + new library → EnableDeviceType(None) before every command →
    ValueError: param must be an int
  • new driver + old library → EnableDeviceType(0) before every command

I hit the first of these while testing, which is how the dependency got pinned
down rather than guessed.

Dropped from the original PRs

8bb9d68 — DT8/DT6/DT1 application-extended sequence wrappers. Rejected by
sde1000, and he is right. #161 — Markus's own commit — made the drivers
auto-prefix EnableDeviceType for bare commands, so trivial wrapper sequences
are redundant; #157 was the same idea, closed by its author for the same reason.
Nothing downstream used them: the HA integration already sends
QueryDimmingCurve and QueryColourTypeFeatures bare through driver.send()
and they work on hardware.

misc.serial / misc.trace_logging aliases. Upstream has since moved
hid.py out of misc/ too, so restoring aliases runs against the direction of
travel. Our integration pins dali-drivers==0.2, which still has the old paths,
so nothing breaks until it bumps — and then it should just follow the move.

6714f15 — example fixup. Moot: python-dali removed its examples in
ce885e7. The firmware example now ships in PR 5 instead.

What changed under us mid-flight

Both upstreams moved while this was being prepared, which invalidated the first
attempt at the split:

  • python-dali c6b4126 → e2dee11, including ce885e7 remove examples
  • dali-drivers 0e7581d → abd1297 (1.0a2 → 1.0a4), including 171c5e7 HID
    driver moved to typed/
    , and upstream gained its own
    tests/test_hid_driver.py

So the drivers changes were rebuilt against typed/hid.py, and the new HID
tests are appended to upstream's file rather than replacing it.

Still open

sde1000/python-dali#171 and sde1000/dali-drivers#8 should be closed with a
pointer to the replacements.

ulrich.huettinger@tridonic.com and others added 4 commits November 25, 2026 14:30
A DALI gateway that emulates control gear answers 254 to
QueryDeviceType, reports part 102 version 1, and implements device
type 0: enabling device type 0 and asking QueryExtendedVersionNumber
gets an answer, and no other device type does.

QueryDeviceTypes took 254 as "no device type" and returned an empty
list, so the gear's device type went unseen. That meaning only arrived
with IEC 62386-102:2014. Annex B of the 2009 edition, the edition this
gear reports, reserves 128 to 254 for control devices and gives
control gear no way to say it has no device type at all, so 254 from
such gear says nothing about what it implements.

Annex A.4 of the 2014 edition covers reading the types in that case:
only the device types the gear implements answer
QueryExtendedVersionNumber, so enabling each in turn and asking
reveals the lot. Use it both for gear answering 254 and for gear that
answers MASK without implementing QueryNextDeviceType to enumerate
with, which previously raised DALISequenceError for gear working
exactly as its edition of the standard says. Gear that really has no
device type answers none of the probes and is still reported as having
none.

The ascending-order check on QueryNextDeviceType answers compared each
against 0 rather than against the previous answer, so a first answer
of 0 was rejected and the order went unchecked after that.

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

This branch has not been deployed

No deployments
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