-
-
Notifications
You must be signed in to change notification settings - Fork 37.6k
Add query button entities to ISY994 devices and hub #85337
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a77c4be
Add query button entities to ISY994 devices and hub
shbatm f710042
Simplify code for button class
shbatm dd99bf4
Merge branch 'dev' into isy994_query_button
shbatm f8a5761
Only use unique_id for entity lookup
shbatm 861c8c6
Cleanup entity_id lookup
shbatm 6352a1f
remove comment
shbatm 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,56 @@ | ||
| """Representation of ISY/IoX buttons.""" | ||
| from __future__ import annotations | ||
|
|
||
| from pyisy import ISY | ||
| from pyisy.nodes import Node | ||
|
|
||
| from homeassistant.components.button import ButtonEntity | ||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.const import Platform | ||
| from homeassistant.core import HomeAssistant | ||
| from homeassistant.helpers.entity import DeviceInfo, EntityCategory | ||
| from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||
|
|
||
| from .const import DOMAIN as ISY994_DOMAIN, ISY994_ISY, ISY994_NODES | ||
|
|
||
|
|
||
| async def async_setup_entry( | ||
| hass: HomeAssistant, | ||
| config_entry: ConfigEntry, | ||
| async_add_entities: AddEntitiesCallback, | ||
| ) -> None: | ||
| """Set up ISY/IoX button from config entry.""" | ||
| hass_isy_data = hass.data[ISY994_DOMAIN][config_entry.entry_id] | ||
| isy: ISY = hass_isy_data[ISY994_ISY] | ||
| uuid = isy.configuration["uuid"] | ||
| entities: list[ISYNodeQueryButtonEntity] = [] | ||
| for node in hass_isy_data[ISY994_NODES][Platform.BUTTON]: | ||
| entities.append(ISYNodeQueryButtonEntity(node, f"{uuid}_{node.address}")) | ||
|
|
||
| # Add entity to query full system | ||
| entities.append(ISYNodeQueryButtonEntity(isy, uuid)) | ||
|
|
||
| async_add_entities(entities) | ||
|
|
||
|
|
||
| class ISYNodeQueryButtonEntity(ButtonEntity): | ||
| """Representation of a device query button entity.""" | ||
|
|
||
| _attr_should_poll = False | ||
| _attr_entity_category = EntityCategory.CONFIG | ||
| _attr_has_entity_name = True | ||
|
|
||
| def __init__(self, node: Node | ISY, base_unique_id: str) -> None: | ||
| """Initialize a query ISY device button entity.""" | ||
| self._node = node | ||
|
|
||
| # Entity class attributes | ||
| self._attr_name = "Query" | ||
| self._attr_unique_id = f"{base_unique_id}_query" | ||
| self._attr_device_info = DeviceInfo( | ||
| identifiers={(ISY994_DOMAIN, base_unique_id)} | ||
| ) | ||
|
|
||
| async def async_press(self) -> None: | ||
| """Press the button.""" | ||
| self.hass.async_create_task(self._node.query()) |
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
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
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.