Skip to content

Add DALI device commands - #23

Merged
SvenHaedrich merged 12 commits into
mainfrom
fix-clear
Mar 22, 2026
Merged

SvenHaedrich merged 12 commits into
mainfrom
fix-clear

Conversation

@SvenHaedrich

Copy link
Copy Markdown
Owner

No description provided.

@github-actions

github-actions Bot commented Mar 4, 2026 •

Copy link
Copy Markdown

✅MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ BASH bash-exec 1 0 0 0.0s
✅ BASH shellcheck 1 0 0 0.02s
✅ BASH shfmt 1 0 0 0.0s
✅ COPYPASTE jscpd yes no no 3.7s
✅ MARKDOWN markdownlint 1 0 0 0.47s
✅ MARKDOWN markdown-table-formatter 1 0 0 0.41s
✅ PYTHON black 32 0 0 2.07s
✅ PYTHON isort 32 0 0 0.3s
✅ PYTHON pylint 32 0 0 9.17s
✅ PYTHON pyright 32 0 0 5.16s
✅ PYTHON ruff 32 0 0 0.02s
✅ REPOSITORY gitleaks yes no no 0.21s
✅ REPOSITORY grype yes no no 36.76s
✅ REPOSITORY secretlint yes no no 1.24s
✅ REPOSITORY trivy yes no no 10.29s
✅ REPOSITORY trufflehog yes no no 4.17s
✅ SPELL cspell 106 0 0 5.27s
✅ SPELL lychee 2 0 0 0.87s

See detailed reports in MegaLinter artifacts

You could have the same capabilities but better runtime performances if you use a MegaLinter flavor:

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.4.0 --custom-flavor-setup --custom-flavor-linters PYTHON_PYLINT,PYTHON_BLACK,PYTHON_ISORT,PYTHON_PYRIGHT,PYTHON_RUFF,BASH_EXEC,BASH_SHELLCHECK,BASH_SHFMT,COPYPASTE_JSCPD,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_GITLEAKS,REPOSITORY_GRYPE,REPOSITORY_SECRETLINT,REPOSITORY_TRIVY,REPOSITORY_TRUFFLEHOG,SPELL_CSPELL,SPELL_LYCHEE

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Add the commands, sort functions according to
DALI standard. Documented missing implementation.
Added all references to the DALI standard.
And some refactorings.
@SvenHaedrich
SvenHaedrich force-pushed the fix-clear branch 5 times, most recently from eb794ce to b6c840e Compare March 4, 2026 15:20
Fix stuff to satisfy the requirements.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the DALI CLI’s device query surface (IEC62386-103-2022-related commands) and updates repository tooling/documentation to support HID-USB adapters and stricter static analysis.

Changes:

  • Add multiple new device query CLI commands (e.g., missing, cycle, application, input) and improve typing/docstrings across several device query functions.
  • Add Lunatone HID-USB udev rules + documentation, and update spellchecker allowlist accordingly.
  • Update tooling/config (MegaLinter major version, Pyright config in pyproject.toml) and adjust dependency declaration for dali-interface.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/cli/test_device_configure.py Minor formatting cleanup in imports.
README.md Documentation tweaks, switch clone URL to HTTPS, add HID-USB/udev instructions.
pyproject.toml Switch dali-interface dependency format; add [tool.pyright] strict config.
dali/DALI/system/membank_annotation.py Add explicit -> None return type for show.
dali/DALI/system/connection.py Simplify dali_interface imports.
dali/DALI/gear/gear_list.py Update help text for gear list.
dali/DALI/gear/gear_clear.py Refactor clear sequence using GearAddress + wait helper and updated constants.
dali/DALI/gear/gear_address.py Modify __str__ signature (type annotation/comment change).
dali/DALI/device/device_query.py Add/reshape many device query commands; add typing/docstrings and new behaviors.
dali/DALI/device/device_dump.py Add typing and a docstring to dump.
dali/DALI/device/device_address.py Remove typeguard usage and add type annotations for constructors.
dali/DALI/device/device_action.py Remove typeguard decorators; keep typed signatures.
dali/dali_cli.py Update banner year; register newly added device query commands.
99-lunatone-dali.rules Add udev rule for Lunatone DALI USB adapter.
.github/workflows/mega-linter.yml Upgrade MegaLinter action reference to v9.
.github/megalinter/cspell.json Add new allowlisted words; minor formatting fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread dali/DALI/device/device_query.py
Comment thread dali/DALI/device/device_query.py Outdated
Comment thread dali/DALI/gear/gear_clear.py Outdated
Comment thread 99-lunatone-dali.rules Outdated
Comment thread .github/workflows/mega-linter.yml
Comment thread pyproject.toml
Comment thread dali/DALI/gear/gear_address.py Outdated
Comment thread dali/dali_cli.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds/extends DALI control gear + control device query functionality and improves developer/ops support (linting, typing, udev rules), with accompanying CLI tests.

Changes:

  • Added/expanded CLI query subcommands for control gear and control devices (e.g., missing short address, application/cycle status, instance input value).
  • Added new CLI tests for gear queries and expanded device-query test coverage for the new commands.
  • Improved project tooling/docs: updated MegaLinter version, added strict Pyright config, added Lunatone udev rules + README instructions, and switched dali-interface dependency spec.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/cli/test_gear_query.py New golden-output tests for gear query commands (mock mode).
tests/cli/test_device_query.py Extends device query parametrized tests to cover new query commands.
tests/cli/test_device_configure.py Minor formatting cleanup.
README.md Documentation updates + new HID-USB/udev section and updated clone URL.
pyproject.toml Switches dali-interface dependency spec; adds strict Pyright configuration.
dali/DALI/system/membank_annotation.py Adds explicit -> None return type for show.
dali/DALI/system/connection.py Import formatting change.
dali/DALI/gear/gear_query.py Implements/updates missing query output handling; adds typing/docstring.
dali/DALI/gear/gear_list.py Updates CLI help text for gear list.
dali/DALI/gear/gear_clear.py Refactors gear clear sequence to use GearAddress + write_gear_frame_and_wait.
dali/DALI/device/device_query.py Adds multiple device query commands and improves typing/docstrings.
dali/DALI/device/device_dump.py Adds type hints and docstring.
dali/DALI/device/device_address.py Removes runtime typeguard usage; adds type hints to constructors.
dali/DALI/device/device_action.py Removes runtime typeguard usage (keeps typed signatures).
dali/dali_cli.py Updates CLI metadata year; registers new device query subcommands.
99-lunatone-dali.rules Adds udev rule file for Lunatone USB adapter access.
.github/workflows/mega-linter.yml Bumps MegaLinter action version.
.github/megalinter/cspell.json Adds new words for spelling checks; formatting fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread tests/cli/test_gear_query.py Outdated
("missing", 0x96),
],
)
def test_query_device_command(command, opcode):

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

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

Test name test_query_device_command is misleading in a gear-query test module (it exercises gear query ...). Renaming it to something like test_query_gear_command would make failures easier to interpret.

Suggested change
def test_query_device_command(command, opcode):
def test_query_gear_command(command, opcode):

Copilot uses AI. Check for mistakes.
Comment thread dali/DALI/device/device_action.py Outdated

@typechecked
def set_device_dtr2_dtr1(dali: DaliInterface, dtr2: int, dtr1: int) -> None:
"""Set control device data transfer registers 0 and 1 simultaneously"""

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

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

The docstring for set_device_dtr2_dtr1 says it sets registers "0 and 1", but the helper (and opcode DTR2_DTR1) sets DTR2 and DTR1. Please correct the docstring to avoid confusion when reusing this helper.

Suggested change
"""Set control device data transfer registers 0 and 1 simultaneously"""
"""Set control device data transfer registers 2 and 1 simultaneously"""

Copilot uses AI. Check for mistakes.
Comment on lines 14 to +24
def clear(dali: DaliInterface):
write_gear_frame(dali, GearSpecialCommandOpcode.INITIALISE, send_twice=True)
set_gear_dtr0(dali, 0xFF)
write_gear_frame_and_wait(dali, GearSpecialCommandOpcode.DTR0, opcode_byte=0xFF)
address = "BC"
gear_send_forward_frame(dali, address, GearConfigureCommandOpcode.SET_SHORT_ADDRESS, True)
dali.get(DaliTimeout.DEFAULT.value)
dali.get(DaliTimeout.DEFAULT.value)
if not dali.data == dali.last_transmit:
click.echo("transmit SET SHORT ADDRESS failed.")
for group in range(DaliMax.GROUP):
gear_send_forward_frame(dali, address, (GearConfigureCommandOpcode.REMOVE_GROUP + group), True)
dali.get(DaliTimeout.DEFAULT.value)
dali.get(DaliTimeout.DEFAULT.value)
if not dali.data == dali.last_transmit:
click.echo(f"transmit REMOVE GROUP {group} failed.")
write_gear_frame(dali, GearSpecialCommandOpcode.TERMINATE)
address = GearAddress()
address.arg("BC")
write_gear_frame_and_wait(dali, address.byte, GearConfigureCommandOpcode.SET_SHORT_ADDRESS, send_twice=True)
for group in range(DaliMax.GEAR_GROUP):
write_gear_frame_and_wait(
dali, address.byte, (GearConfigureCommandOpcode.REMOVE_GROUP + group), send_twice=True
)
write_gear_frame(dali, GearSpecialCommandOpcode.TERMINATE)

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

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

gear_clear.clear() was substantially refactored (now uses GearAddress + write_gear_frame_and_wait and iterates DaliMax.GEAR_GROUP), but there are no CLI tests covering the gear clear command (searching tests/cli shows none). Given the repo has extensive CLI golden-output tests for other gear commands, please add a basic mock-based test for gear clear to lock in the expected transmitted frames/order.

Copilot uses AI. Check for mistakes.
SvenHaedrich and others added 3 commits March 22, 2026 20:20
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SvenHaedrich
SvenHaedrich merged commit f95f5a3 into main Mar 22, 2026
1 check passed
@SvenHaedrich
SvenHaedrich deleted the fix-clear branch March 22, 2026 20:54
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