Archived
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""Button entity for Boiler Auxiliary Heater Control."""
|
|
|
|
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 import DeviceInfo
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
|
|
from .const import DOMAIN
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
entry: ConfigEntry,
|
|
async_add_entities: AddEntitiesCallback,
|
|
) -> None:
|
|
"""Set up button entities."""
|
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
|
|
|
# Only create bath boost button if circulation pump is configured
|
|
if coordinator.circulation_pump:
|
|
async_add_entities(
|
|
[BoilerBathBoostButton(coordinator, entry)]
|
|
)
|
|
|
|
|
|
class BoilerBathBoostButton(ButtonEntity):
|
|
"""Button to start the bath boost timer."""
|
|
|
|
_attr_has_entity_name = True
|
|
_attr_translation_key = "start_bath_boost"
|
|
_attr_icon = "mdi:bath"
|
|
|
|
def __init__(self, coordinator, entry: ConfigEntry) -> None:
|
|
"""Initialize the button."""
|
|
self.coordinator = coordinator
|
|
self._attr_unique_id = f"{entry.entry_id}_start_bath_boost"
|
|
self._attr_device_info = DeviceInfo(
|
|
identifiers={(DOMAIN, entry.entry_id)},
|
|
name="Boiler Auxiliary Heater",
|
|
manufacturer="Custom",
|
|
)
|
|
|
|
async def async_press(self) -> None:
|
|
"""Handle button press - start bath boost."""
|
|
await self.coordinator.async_start_bath_boost()
|