Adjust button type hints in components (#74132)
parent
dc039f5218
commit
b51ad16db9
|
@ -30,7 +30,7 @@ class AugustWakeLockButton(AugustEntityMixin, ButtonEntity):
|
|||
self._attr_name = f"{device.device_name} Wake"
|
||||
self._attr_unique_id = f"{self._device_id}_wake"
|
||||
|
||||
async def async_press(self, **kwargs):
|
||||
async def async_press(self) -> None:
|
||||
"""Wake the device."""
|
||||
await self._data.async_status_async(self._device_id, self._hyper_bridge)
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from bond_async import Action, BPUPSubscriptions
|
||||
|
||||
|
@ -290,7 +289,7 @@ class BondButtonEntity(BondEntity, ButtonEntity):
|
|||
hub, device, bpup_subs, description.name, description.key.lower()
|
||||
)
|
||||
|
||||
async def async_press(self, **kwargs: Any) -> None:
|
||||
async def async_press(self) -> None:
|
||||
"""Press the button."""
|
||||
if self.entity_description.argument:
|
||||
action = Action(
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from contextlib import suppress
|
||||
from typing import Any
|
||||
|
||||
from aioesphomeapi import ButtonInfo, EntityState
|
||||
|
||||
|
@ -46,6 +45,6 @@ class EsphomeButton(EsphomeEntity[ButtonInfo, EntityState], ButtonEntity):
|
|||
# never gets a state update.
|
||||
self._on_state_update()
|
||||
|
||||
async def async_press(self, **kwargs: Any) -> None:
|
||||
async def async_press(self) -> None:
|
||||
"""Press the button."""
|
||||
await self._client.button_command(self._static_info.key)
|
||||
|
|
|
@ -130,7 +130,7 @@ class MqttButton(MqttEntity, ButtonEntity):
|
|||
"""Return the device class of the sensor."""
|
||||
return self._config.get(CONF_DEVICE_CLASS)
|
||||
|
||||
async def async_press(self, **kwargs):
|
||||
async def async_press(self) -> None:
|
||||
"""Turn the device on.
|
||||
|
||||
This method is a coroutine.
|
||||
|
|
|
@ -5,6 +5,7 @@ from homeassistant.components.button import ButtonEntity
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
|
@ -54,7 +55,7 @@ class OctoprintButton(CoordinatorEntity[OctoprintDataUpdateCoordinator], ButtonE
|
|||
self._attr_unique_id = f"{button_type}-{device_id}"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Device info."""
|
||||
return self.coordinator.device_info
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Support for Tuya buttons."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from tuya_iot import TuyaDevice, TuyaDeviceManager
|
||||
|
||||
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
||||
|
@ -109,6 +107,6 @@ class TuyaButtonEntity(TuyaEntity, ButtonEntity):
|
|||
self.entity_description = description
|
||||
self._attr_unique_id = f"{super().unique_id}{description.key}"
|
||||
|
||||
def press(self, **kwargs: Any) -> None:
|
||||
def press(self) -> None:
|
||||
"""Press the button."""
|
||||
self._send_command([{"code": self.entity_description.key, "value": True}])
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.button import (
|
||||
ButtonDeviceClass,
|
||||
|
@ -111,7 +110,7 @@ class XiaomiGenericCoordinatedButton(XiaomiCoordinatedMiioEntity, ButtonEntity):
|
|||
super().__init__(name, device, entry, unique_id, coordinator)
|
||||
self.entity_description = description
|
||||
|
||||
async def async_press(self, **kwargs: Any) -> None:
|
||||
async def async_press(self) -> None:
|
||||
"""Press the button."""
|
||||
method = getattr(self._device, self.entity_description.method_press)
|
||||
await self._try_command(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for Yale Smart Alarm button."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -50,7 +50,7 @@ class YalePanicButton(YaleAlarmEntity, ButtonEntity):
|
|||
self._attr_name = f"{coordinator.entry.data[CONF_NAME]} {description.name}"
|
||||
self._attr_unique_id = f"yale_smart_alarm-{description.key}"
|
||||
|
||||
async def async_press(self, **kwargs: Any) -> None:
|
||||
async def async_press(self) -> None:
|
||||
"""Press the button."""
|
||||
if TYPE_CHECKING:
|
||||
assert self.coordinator.yale, "Connection to API is missing"
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
"""Representation of a toggleButton."""
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.button import ButtonEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -41,6 +39,6 @@ async def async_setup_entry(
|
|||
class ZWaveMeButton(ZWaveMeEntity, ButtonEntity):
|
||||
"""Representation of a ZWaveMe button."""
|
||||
|
||||
def press(self, **kwargs: Any) -> None:
|
||||
def press(self) -> None:
|
||||
"""Turn the entity on."""
|
||||
self.controller.zwave_api.send_command(self.device.id, "on")
|
||||
|
|
Loading…
Reference in New Issue