Skip to content

Add DALI scan binary sensor to lunatone - #179068

Draft
MoonDevLT wants to merge 6 commits into
home-assistant:devfrom
MoonDevLT:lunatone/add-dali-scan-binary-sensor
Draft

Add DALI scan binary sensor to lunatone#179068
MoonDevLT wants to merge 6 commits into
home-assistant:devfrom
MoonDevLT:lunatone/add-dali-scan-binary-sensor

Conversation

@MoonDevLT

@MoonDevLT MoonDevLT commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Breaking change

Proposed change

Add DALI scan binary sensor to monitor the state of a DALI scan.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Align constant names with the `update_interval` parameter used by `DataUpdateCoordinator` for improved clarity.
When the DALI scan API reports as busy, temporarily reduce the update interval to 1 second. This allows for quicker status updates during active scanning improving responsiveness.

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 a diagnostic binary sensor showing whether a Lunatone DALI scan is running.

Changes:

  • Adds adaptive DALI scan polling.
  • Registers the binary sensor and translation.
  • Updates fixtures and setup-failure tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
homeassistant/components/lunatone/__init__.py Initializes scan coordination and platform.
homeassistant/components/lunatone/binary_sensor.py Implements the scan-status entity.
homeassistant/components/lunatone/coordinator.py Adds adaptive scan polling.
homeassistant/components/lunatone/strings.json Adds the entity name.
tests/components/lunatone/conftest.py Adds the scan API fixture.
tests/components/lunatone/test_config_flow.py Activates the fixture in flow tests.
tests/components/lunatone/test_diagnostics.py Activates the fixture in diagnostics tests.
tests/components/lunatone/test_init.py Tests scan setup failures.
tests/components/lunatone/test_light.py Activates the fixture in light tests.
tests/components/lunatone/test_sensor.py Activates the fixture in sensor tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +31 to +33
async_add_entities(
[LunatoneDALIScanStatus(coordinator_scan, config_entry.unique_id)]
)
Comment on lines +192 to +195
update_interval = DEFAULT_SCAN_UPDATE_INTERVAL
if self.dali_scan_api.is_busy:
update_interval = timedelta(seconds=1)
self.update_interval = update_interval
@MoonDevLT
MoonDevLT marked this pull request as ready for review August 13, 2026 12:02
Copilot AI review requested due to automatic review settings August 14, 2026 10:48

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Suppressed comments (3)

homeassistant/components/lunatone/binary_sensor.py:33

  • Add binary-sensor tests that exercise idle and running scan states. No test currently asserts that this new entity is created with the expected identity or that coordinator refreshes update its state and availability, so the primary feature is unverified despite the integration declaring test coverage complete.
    async_add_entities(
        [LunatoneDALIScanStatus(coordinator_scan, config_entry.unique_id)]
    )

tests/components/lunatone/conftest.py:172

  • Initialize the scan mock with concrete idle ScanData and is_busy values. As written, both attributes remain truthy mock objects, so every existing setup test silently exercises a running scan with the one-second polling interval and cannot validate the new entity's actual state mapping.
        scan = mock_dali_scan.return_value
        yield scan

tests/components/lunatone/test_init.py:138

  • Correct this docstring to refer to the scan API. This test configures mock_lunatone_scan, not the sensors API.
    """Test config entry not ready due to sensors API failure."""

@joostlek joostlek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we also add tests for the binary sensor?

Comment on lines +51 to +59
self.entity_category = EntityCategory.DIAGNOSTIC

self._config_entry_unique_id = config_entry_unique_id

self._attr_unique_id = f"{config_entry_unique_id}-scan-progress"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._config_entry_unique_id)},
)
self._attr_translation_key = "scan_status"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

entity category and translation key can be set outside of the constructor

@home-assistant
home-assistant Bot marked this pull request as draft August 14, 2026 10:58
@home-assistant

Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants