Repository navigation
Conversation
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>
# Conflicts: # CHANGES.rst
…types # Conflicts: # CHANGES.rst
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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-typesScope: 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
254toQUERY DEVICE TYPEwhile implementing device type 0.
QueryDeviceTypestook that as "no devicetype" 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
254from 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:
QueryVersionNumber1— part 102 edition 1QueryDeviceType(×3)254, consistentlyQueryNextDeviceTypeEnableDeviceType(0)+QueryExtendedVersionNumber1EnableDeviceType(1…15)+QueryExtendedVersionNumberQueryExtendedVersionNumberwith no prefixThe last row is the control: the gear does honour
EnableDeviceType, so thesingle 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 FAILUREorQUERY RESET STATEalthough part 102 requires them, and it quantisesDAPC(128 reads back as 126). It is emulating, not implementing.
The change
QueryDeviceTypesfalls back to the Annex A.4 probe in two cases:254, because that answer is ambiguous across editionsMASKwithout implementingQueryNextDeviceTypeto enumeratewith, which previously raised
DALISequenceErrorfor gear behaving exactly asits 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 whereverit is true.
Also fixes the ascending-order check on
QueryNextDeviceTypeanswers: itcompared each answer against
0rather than against the previous answer, so afirst answer of
0was rejected and the order went unchecked after that.On the probe and
EnableDeviceTypeThe probe yields
EnableDeviceType(n)explicitly and then the plaindali.gear.general.QueryExtendedVersionNumber, whosedevicetypeis 0, so thedriver 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
devicetypeoff. It is not a reinventionof the driver's own
EnableDeviceTypehandling (#161).Testing
pytest dali/— 137 passed; the three new tests fail without the changemypy --strict dali/— clean, 45 filesflake8 dali— 0QueryDeviceTypesreturns[]before and
[0]after🤖 Generated with Claude Code
Upstream PR coordination — DT0 / EnableDeviceType(0) / firmware transfer
Replaces
sde1000/python-dali#171andsde1000/dali-drivers#8, both of whichbundled independent features. Five PRs, each standing alone.
The five
pr-device-typespr-enable-device-type-0pr-firmwaredd-enable-device-type-0dd-32bit-framesAll five:
mypy --strictclean,flake80, working tree clean, rebased ontocurrent upstream (
python-dalie2dee11,dali-driversabd1297 / 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_requireshas to name it.Why PR 4 must not jump the queue
The drivers decide whether to prefix by testing
cmd.devicetype. PR 2 changesthe "no prefix" value from
0toNone. Either half alone is broken:EnableDeviceType(None)before every command →ValueError: param must be an intEnableDeviceType(0)before every commandI 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 bysde1000, and he is right. #161 — Markus's own commit — made the drivers
auto-prefix
EnableDeviceTypefor bare commands, so trivial wrapper sequencesare redundant; #157 was the same idea, closed by its author for the same reason.
Nothing downstream used them: the HA integration already sends
QueryDimmingCurveandQueryColourTypeFeaturesbare throughdriver.send()and they work on hardware.
misc.serial/misc.trace_loggingaliases. Upstream has since movedhid.pyout ofmisc/too, so restoring aliases runs against the direction oftravel. 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 ince885e7. 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:
c6b4126 → e2dee11, includingce885e7remove examples0e7581d → abd1297(1.0a2 → 1.0a4), including171c5e7HIDdriver moved to
typed/, and upstream gained its owntests/test_hid_driver.pySo the drivers changes were rebuilt against
typed/hid.py, and the new HIDtests are appended to upstream's file rather than replacing it.
Still open
sde1000/python-dali#171andsde1000/dali-drivers#8should be closed with apointer to the replacements.