hass-core/homeassistant/components/august/button.py
J. Nick Koston a04970bd54
Address august review comments (#124819)
* Address august review comments

Followup to https://github.com/home-assistant/core/pull/124677

* cleanup loop

* drop mixin name

* event entity add cleanup

* remove duplicate prop

* pep0695 type

* remove some not needed block till done

* cleanup august tests

* switch to freezegun

* snapshots for dev reg

* SOURCE_USER nit

* snapshots

* pytest.raises

* not loaded check
2024-08-29 19:32:13 +02:00

32 lines
1,018 B
Python

"""Support for August buttons."""
from homeassistant.components.button import ButtonEntity
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import AugustConfigEntry
from .entity import AugustEntity
async def async_setup_entry(
hass: HomeAssistant,
config_entry: AugustConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up August lock wake buttons."""
data = config_entry.runtime_data
async_add_entities(AugustWakeLockButton(data, lock, "wake") for lock in data.locks)
class AugustWakeLockButton(AugustEntity, ButtonEntity):
"""Representation of an August lock wake button."""
_attr_translation_key = "wake"
async def async_press(self) -> None:
"""Wake the device."""
await self._data.async_status_async(self._device_id, self._hyper_bridge)
@callback
def _update_from_data(self) -> None:
"""Nothing to update as buttons are stateless."""