Add DALI device commands - #23
Conversation
✅MegaLinter analysis: Success
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
|
Add the commands, sort functions according to DALI standard. Documented missing implementation. Added all references to the DALI standard.
And some refactorings.
eb794ce to
b6c840e
Compare
Fix stuff to satisfy the requirements.
There was a problem hiding this comment.
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 queryCLI 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 fordali-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.
There was a problem hiding this comment.
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-interfacedependency 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.
| ("missing", 0x96), | ||
| ], | ||
| ) | ||
| def test_query_device_command(command, opcode): |
There was a problem hiding this comment.
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.
| def test_query_device_command(command, opcode): | |
| def test_query_gear_command(command, opcode): |
|
|
||
| @typechecked | ||
| def set_device_dtr2_dtr1(dali: DaliInterface, dtr2: int, dtr1: int) -> None: | ||
| """Set control device data transfer registers 0 and 1 simultaneously""" |
There was a problem hiding this comment.
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.
| """Set control device data transfer registers 0 and 1 simultaneously""" | |
| """Set control device data transfer registers 2 and 1 simultaneously""" |
| 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) |
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

No description provided.