-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
38 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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 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,26 @@ | ||
from homeassistant.components.button import ButtonEntity | ||
|
||
from .core.entity import YandexCustomEntity | ||
from .hass import hass_utils | ||
|
||
INCLUDE_CAPABILITIES = ("devices.capabilities.custom.button",) | ||
|
||
|
||
async def async_setup_entry(hass, entry, async_add_entities): | ||
entities = [] | ||
|
||
for quasar, device, config in hass_utils.incluce_devices(hass, entry): | ||
if instances := config.get("capabilities"): | ||
for instance in device["capabilities"]: | ||
if instance["type"] not in INCLUDE_CAPABILITIES: | ||
continue | ||
if instance["parameters"].get("instance", "on") in instances: | ||
entities.append(YandexCustomButton(quasar, device, instance)) | ||
|
||
async_add_entities(entities) | ||
|
||
|
||
# noinspection PyAbstractClass | ||
class YandexCustomButton(ButtonEntity, YandexCustomEntity): | ||
async def async_press(self) -> None: | ||
await self.quasar.device_action(self.device["id"], self.instance, True) |
This file contains 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 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 was deleted.
Oops, something went wrong.