Skip to content

Allow commands to ask for EnableDeviceType(0) - #175

Merged
sde1000 merged 1 commit into
sde1000:masterfrom
tridonic-com:pr-enable-device-type-0
Nov 27, 2026
Merged

sde1000 merged 1 commit into
sde1000:masterfrom
tridonic-com:pr-enable-device-type-0

Conversation

@huetti79

Copy link
Copy Markdown

PR 2 — python-dali: allow commands to ask for EnableDeviceType(0)

Open at: https://github.com/tridonic-com/python-dali/pull/new/pr-enable-device-type-0
Base: sde1000/python-dali:master ← tridonic-com:pr-enable-device-type-0
Scope: 1 commit, 7 files, +84 / −36 · independent of the other two python-dali PRs
⚠️ Breaking change — see "Downstream impact"


Split out of #171 as requested.

The problem

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.devicetype could not express that: 0 was the value
meaning "send this command on its own".

The consequences were baked in — EnableDeviceType was documented as unusable
for device type 0, and part 201 could not be implemented at all.

The change

None now means "no EnableDeviceType needed". That leaves every value the
standard allows for the parameter, 0 to 254, free to mean the device type it
names.

Command.from_frame()'s devicetype parameter follows suit, so a frame that
was not preceded by EnableDeviceType no longer decodes as one that was
preceded by EnableDeviceType(0) — previously indistinguishable.

Adds dali.gear.fluorescent with the single application extended command part
201 defines, QueryExtendedVersionNumber.

Downstream impact

Code passing devicetype=0 to mean "none" must pass None instead.

In particular the drivers test cmd.devicetype to decide whether to prefix:
against this change an unmodified driver would prefix every general command
with EnableDeviceType(0) rather than none of them. The companion
dali-drivers PR makes that test is not None, and bumps its
install_requires accordingly. That PR must not merge before this one, and
this one should land in a release the drivers can require.

With both in place, dali-drivers' existing
test_dummy_send_no_prefix_for_general_command still passes: a general command
has devicetype is None, so it is still sent on its own.

Testing

  • pytest dali/ — 133 passed
  • mypy --strict dali/ — clean, 46 files
  • flake8 dali — 0

🤖 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.

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>
@sde1000

sde1000 commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Ok, this looks good to me. I'll merge this and the driver change and make a simultaneous release of both packages when I get home later today.

@sde1000
sde1000 merged commit ecab334 into sde1000:master Nov 27, 2026
6 checks passed
@markus-becker-tridonic-com
markus-becker-tridonic-com deleted the pr-enable-device-type-0 branch November 27, 2026 08:50
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