-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Add scene platform for Sunricher DALI integration #157808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
niracler
wants to merge
9
commits into
home-assistant:dev
Choose a base branch
from
niracler:feat/sunricher-dali-scene
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a5c3559
feat(sunricher_dali): add scene platform
niracler 31443c6
feat(sunricher_dali): add scene platform
niracler d3a9379
add PARALLEL_UPDATES
niracler 8e971c9
fix(sunricher_dali): remove debug logging and improve test coverage
niracler 219901b
refactor(sunricher_dali): optimize test structure
niracler 6ab265e
Add base entity for Sunricher DALI
niracler 1f9ea82
deps: update PySrDaliGateway to 0.18.0
niracler 323384c
refactor(sunricher_dali): extract DaliDeviceEntity class
niracler 0b6d5ef
Merge branch 'dev' into feat/sunricher-dali-scene
niracler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| """Base entity for Sunricher DALI integration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
|
|
||
| from PySrDaliGateway import CallbackEventType, DaliObjectBase, Device | ||
|
Check failure on line 7 in homeassistant/components/sunricher_dali/entity.py
|
||
|
|
||
| from homeassistant.core import callback | ||
| from homeassistant.helpers.entity import Entity | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class DaliCenterEntity(Entity): | ||
| """Base entity for DALI Center objects (devices, scenes, etc.).""" | ||
|
|
||
| _attr_has_entity_name = True | ||
| _attr_should_poll = False | ||
|
|
||
| def __init__(self, dali_object: DaliObjectBase) -> None: | ||
| """Initialize base entity.""" | ||
| self._dali_object = dali_object | ||
| self._attr_unique_id = dali_object.unique_id | ||
| self._unavailable_logged = False | ||
| # Set initial availability from status if available (Device has it, Scene doesn't) | ||
| if isinstance(dali_object, Device): | ||
| self._attr_available = dali_object.status == "online" | ||
| else: | ||
| self._attr_available = True | ||
|
|
||
| async def async_added_to_hass(self) -> None: | ||
| """Register availability listener.""" | ||
| self.async_on_remove( | ||
| self._dali_object.register_listener( | ||
| CallbackEventType.ONLINE_STATUS, | ||
| self._handle_availability, | ||
| ) | ||
| ) | ||
|
|
||
| @callback | ||
| def _handle_availability(self, available: bool) -> None: | ||
| """Handle availability changes.""" | ||
| # Log availability transitions | ||
| if not available and not self._unavailable_logged: | ||
| _LOGGER.info("Entity %s became unavailable", self.entity_id) | ||
| self._unavailable_logged = True | ||
| elif available and self._unavailable_logged: | ||
| _LOGGER.info("Entity %s is back online", self.entity_id) | ||
| self._unavailable_logged = False | ||
|
|
||
| self._attr_available = available | ||
| self.schedule_update_ha_state() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.