Add DALI scan binary sensor to lunatone - #179068
Conversation
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.
There was a problem hiding this comment.
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.
| async_add_entities( | ||
| [LunatoneDALIScanStatus(coordinator_scan, config_entry.unique_id)] | ||
| ) |
| update_interval = DEFAULT_SCAN_UPDATE_INTERVAL | ||
| if self.dali_scan_api.is_busy: | ||
| update_interval = timedelta(seconds=1) | ||
| self.update_interval = update_interval |
There was a problem hiding this comment.
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
ScanDataandis_busyvalues. 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
left a comment
There was a problem hiding this comment.
Can we also add tests for the binary sensor?
| 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" |
There was a problem hiding this comment.
entity category and translation key can be set outside of the constructor
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Breaking change
Proposed change
Add DALI scan binary sensor to monitor the state of a DALI scan.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: