Skip to content
Snippets Groups Projects
Unverified Commit 807d197c authored by Mick Vleeshouwer's avatar Mick Vleeshouwer Committed by GitHub
Browse files

Add goToAlias button (my position) to Overkiz integration (#76694)

parent 9a6b22a1
No related branches found
No related tags found
No related merge requests found
"""Support for Overkiz (virtual) buttons.""" """Support for Overkiz (virtual) buttons."""
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass
from pyoverkiz.types import StateType as OverkizStateType
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
...@@ -11,41 +15,56 @@ from . import HomeAssistantOverkizData ...@@ -11,41 +15,56 @@ from . import HomeAssistantOverkizData
from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES
from .entity import OverkizDescriptiveEntity from .entity import OverkizDescriptiveEntity
BUTTON_DESCRIPTIONS: list[ButtonEntityDescription] = [
@dataclass
class OverkizButtonDescription(ButtonEntityDescription):
"""Class to describe an Overkiz button."""
press_args: OverkizStateType | None = None
BUTTON_DESCRIPTIONS: list[OverkizButtonDescription] = [
# My Position (cover, light) # My Position (cover, light)
ButtonEntityDescription( OverkizButtonDescription(
key="my", key="my",
name="My Position", name="My Position",
icon="mdi:star", icon="mdi:star",
), ),
# Identify # Identify
ButtonEntityDescription( OverkizButtonDescription(
key="identify", # startIdentify and identify are reversed... Swap this when fixed in API. key="identify", # startIdentify and identify are reversed... Swap this when fixed in API.
name="Start Identify", name="Start Identify",
icon="mdi:human-greeting-variant", icon="mdi:human-greeting-variant",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
ButtonEntityDescription( OverkizButtonDescription(
key="stopIdentify", key="stopIdentify",
name="Stop Identify", name="Stop Identify",
icon="mdi:human-greeting-variant", icon="mdi:human-greeting-variant",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
ButtonEntityDescription( OverkizButtonDescription(
key="startIdentify", # startIdentify and identify are reversed... Swap this when fixed in API. key="startIdentify", # startIdentify and identify are reversed... Swap this when fixed in API.
name="Identify", name="Identify",
icon="mdi:human-greeting-variant", icon="mdi:human-greeting-variant",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
# RTDIndoorSiren / RTDOutdoorSiren # RTDIndoorSiren / RTDOutdoorSiren
ButtonEntityDescription(key="dingDong", name="Ding Dong", icon="mdi:bell-ring"), OverkizButtonDescription(key="dingDong", name="Ding Dong", icon="mdi:bell-ring"),
ButtonEntityDescription(key="bip", name="Bip", icon="mdi:bell-ring"), OverkizButtonDescription(key="bip", name="Bip", icon="mdi:bell-ring"),
ButtonEntityDescription( OverkizButtonDescription(
key="fastBipSequence", name="Fast Bip Sequence", icon="mdi:bell-ring" key="fastBipSequence", name="Fast Bip Sequence", icon="mdi:bell-ring"
), ),
ButtonEntityDescription(key="ring", name="Ring", icon="mdi:bell-ring"), OverkizButtonDescription(key="ring", name="Ring", icon="mdi:bell-ring"),
# DynamicScreen (ogp:blind) uses goToAlias (id 1: favorite1) instead of 'my'
OverkizButtonDescription(
key="goToAlias",
press_args="1",
name="My position",
icon="mdi:star",
),
] ]
SUPPORTED_COMMANDS = { SUPPORTED_COMMANDS = {
...@@ -85,6 +104,14 @@ async def async_setup_entry( ...@@ -85,6 +104,14 @@ async def async_setup_entry(
class OverkizButton(OverkizDescriptiveEntity, ButtonEntity): class OverkizButton(OverkizDescriptiveEntity, ButtonEntity):
"""Representation of an Overkiz Button.""" """Representation of an Overkiz Button."""
entity_description: OverkizButtonDescription
async def async_press(self) -> None: async def async_press(self) -> None:
"""Handle the button press.""" """Handle the button press."""
if self.entity_description.press_args:
await self.executor.async_execute_command(
self.entity_description.key, self.entity_description.press_args
)
return
await self.executor.async_execute_command(self.entity_description.key) await self.executor.async_execute_command(self.entity_description.key)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment