35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""Button entities for Sternwarte."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from homeassistant.components.button import ButtonEntity
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
|
|
from .const import DOMAIN, ENTITY_SET_NAUTICAL_SCHEDULE
|
|
from .entity import SternwarteEntity
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
entry: ConfigEntry,
|
|
async_add_entities: AddEntitiesCallback,
|
|
) -> None:
|
|
"""Set up Sternwarte buttons."""
|
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
|
async_add_entities([SternwarteSetNauticalScheduleButton(coordinator)])
|
|
|
|
|
|
class SternwarteSetNauticalScheduleButton(SternwarteEntity, ButtonEntity):
|
|
"""Button to set the next nautical dusk/dawn schedule."""
|
|
|
|
_attr_name = "Nautische Dämmerung setzen"
|
|
_attr_icon = "mdi:weather-night"
|
|
|
|
def __init__(self, coordinator):
|
|
super().__init__(coordinator, ENTITY_SET_NAUTICAL_SCHEDULE)
|
|
|
|
async def async_press(self) -> None:
|
|
await self.coordinator.async_set_next_nautical_schedule()
|