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>
An application extended command is ignored unless EnableDeviceType for its part 2xx type immediately precedes it, which a caller sending the command on its own does not get. Three queries and the DT1 commands were left without the sequence wrapper that arranges it. QueryDT8ColourTypeFeatures and QueryDT8ColourStatus report which colour types a gear supports and which one is active; QueryDT6DimmingCurve reports the configured curve, so a linear one can be told from the standard logarithmic one. EmergencyCommand carries any single DT1 command, the tests, resets and mode changes among them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Device type 0 is fluorescent lamp control gear, IEC 62386-201, and its application extended commands must be preceded by EnableDeviceType(0) just like those of any other device type. Command.devicetype could not express that: 0 was the value meaning "send this command on its own", so EnableDeviceType was documented as unusable for device type 0, and part 201 could not be implemented at all. Use None for "no EnableDeviceType needed" instead, which leaves every value the standard allows for the command parameter, 0 to 254, free to mean the device type it names. The devicetype parameter of from_frame follows suit, so a frame that was not preceded by EnableDeviceType no longer decodes as one that was preceded by EnableDeviceType(0). Add dali.gear.fluorescent with the one application extended command part 201 defines, QueryExtendedVersionNumber; opcodes 224 to 254 are reserved there and control gear shall not react to them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Firmware transfer uses 32-bit forward frames which carry their destination in the most significant byte, so the addresses are a family of their own rather than a variant of GearAddress or DeviceAddress: a transfer is addressed to a bus unit whether that unit is control gear or a control device. Add dali.firmware with the commands and dali.firmware_sequences with the sequences that drive an image onto a unit and that find the units supporting transfer at all. The order of the commands has been inferred from the command set, not read out of the standard, so check it against IEC 62386-105 before running it against hardware. The drivers that carry 32-bit frames live in dali-drivers; this is the library half only. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
|
This pull request needs splitting into multiple parts. Commit 0956cbb should be a separate pull request. I need to sanity check it against the standards before accepting it. Commit 8bb9d68 will be rejected — see pull request #157. You have misunderstood how drivers are supposed to process commands that require Commit 2a14be1 should be a separate pull request. Commits 4f013aa and 6714f15 should be a separate pull request. Support for firmware updates over 32-bit frames is a major new feature and needs considering on its own. |
This was referenced Nov 25, 2026
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 description — sde1000/python-dali
Branch:
tridonic-com/python-dali:dt0-device-type-support-typing→sde1000/python-dali:masterScope: 5 commits, 18 files, +1715 / −45
1. Read the device types of gear that does not report them
A DALI gateway that emulates control gear answers
254toQUERY DEVICE TYPEwhileimplementing device type 0.
QueryDeviceTypestook that as "no device type" andreturned an empty list, so the gear's device type went unseen.
That meaning only arrives 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
254from such gear says nothingabout what it implements.
Measured on the device (Lunatone DALI-2 USB PS, art. 24138246, on a 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 the singleanswer at device type 0 is the Annex A.4 signature and not an artefact.
This falls back to the Annex A.4 probe for gear answering
254, and for gear thatanswers
MASKwithout implementingQueryNextDeviceTypeto enumerate with — whichpreviously raised
DALISequenceErrorfor gear working exactly as its edition of thestandard says. Gear that genuinely has no device type answers none of the probes and
is still reported as having none.
Also fixes the ascending-order check on
QueryNextDeviceTypeanswers, which comparedeach answer against
0rather than against the previous one, so a first answer of0was rejected and the order went unchecked thereafter.
2. Application-extended sequences for DT8, DT6 and DT1
An application extended command is ignored unless
EnableDeviceTypefor its part 2xxtype immediately precedes it, which a caller sending the command on its own does not
get. Adds the sequence wrappers that arrange it:
QueryDT8ColourTypeFeatures,QueryDT8ColourStatus— which colour types a gearsupports and which is active
QueryDT6DimmingCurve— tells a linear curve from the standard logarithmic oneEmergencyCommand— carries any single DT1 command, the tests, resets and modechanges among them
3. Allow commands to ask for⚠️ breaking
EnableDeviceType(0)Device type 0 is fluorescent lamp control gear, IEC 62386-201, and its application
extended commands must be preceded by
EnableDeviceType(0)like any other type's.Command.devicetypecould not express that:0was the value meaning "send thiscommand on its own", so
EnableDeviceTypewas documented as unusable for devicetype 0 and part 201 could not be implemented at all.
Nonenow means "noEnableDeviceTypeneeded", which leaves every value the standardallows for the parameter, 0 to 254, free to mean the device type it names. The
devicetypeparameter offrom_frame()follows suit, so a frame that was notpreceded by
EnableDeviceTypeno longer decodes as one that was preceded byEnableDeviceType(0).Downstream impact: code passing
devicetype=0to mean "none" must passNone.The companion driver change is a separate PR against
dali-drivers; see the note atthe bottom.
Adds
dali.gear.fluorescentwith the single application extended command part 201defines,
QueryExtendedVersionNumber.4. Firmware transfer (IEC 62386-105)⚠️ please read
Firmware transfer uses 32-bit forward frames carrying their destination in the most
significant byte, so the addresses are a family of their own rather than a variant of
GearAddressorDeviceAddress: a transfer is addressed to a bus unit whether thatunit is control gear or a control device.
dali.firmware— the commands, plus aFirmwareAddressfamily indali.addressdali.firmware_sequences— sequences that drive an image onto a unit and that findthe units supporting transfer at all
examples/async-firmware-update.pyCaveat: the order of the commands in these sequences has been inferred from the
command set, not read out of IEC 62386-105, and has not been run against hardware that
accepts a firmware image. The commands and framing are exercised by unit tests only.
Please treat this part as needing a check against the standard before release — it is
why I would be happy to see it split into its own PR.
Testing
pytest dali/— 175 passedmypy --strict dali/— clean (the branch keeps the typing baseline:masterbefore this change is also clean at 46 files, this is clean at 50)
flake8 dali— 0PS + the emulating gateway above):
QueryDeviceTypesreturns[]before the changeand
[0]after it, and the new tests fail without the change.CHANGES.rstis updated for each item.Notes for the reviewer
masterwithupstream/mastermerged in, so it already carries the typingrework and release 1.0a2.
dali/firmware.pyuses__init_subclass__rather than the removedCommand._register_subclass().dali-driverscarries the driver halves of items 3 and 4.It must not merge before this one: with a driver checking
cmd.devicetype is not Noneagainst a library where the default is still0, everygeneral command would be prefixed with
EnableDeviceType(0).🤖 Generated with Claude Code