forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tami4 integration boil water button (home-assistant#103400)
* Implement boil water button * Sort platforms list * Get API directly * Cleanup * Rename boil button string Co-authored-by: Joost Lekkerkerker <[email protected]> * Add button to .coveragerc * Change ButtonEntityDescription to EntityDescription * Update homeassistant/components/tami4/button.py * Update homeassistant/components/tami4/button.py --------- Co-authored-by: Joost Lekkerkerker <[email protected]>
- Loading branch information
Showing
4 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Button entities for Tami4Edge.""" | ||
import logging | ||
|
||
from Tami4EdgeAPI import Tami4EdgeAPI | ||
|
||
from homeassistant.components.button import ButtonEntity | ||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers.entity import EntityDescription | ||
from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||
|
||
from .const import API, DOMAIN | ||
from .entity import Tami4EdgeBaseEntity | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
ENTITY_DESCRIPTION = EntityDescription( | ||
key="boil_water", | ||
translation_key="boil_water", | ||
icon="mdi:kettle-steam", | ||
) | ||
|
||
|
||
async def async_setup_entry( | ||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback | ||
) -> None: | ||
"""Perform the setup for Tami4Edge.""" | ||
api: Tami4EdgeAPI = hass.data[DOMAIN][entry.entry_id][API] | ||
|
||
async_add_entities([Tami4EdgeBoilButton(api)]) | ||
|
||
|
||
class Tami4EdgeBoilButton(Tami4EdgeBaseEntity, ButtonEntity): | ||
"""Boil button entity for Tami4Edge.""" | ||
|
||
def __init__(self, api: Tami4EdgeAPI) -> None: | ||
"""Initialize the button entity.""" | ||
super().__init__(api, ENTITY_DESCRIPTION) | ||
|
||
def press(self) -> None: | ||
"""Handle the button press.""" | ||
self._api.boil_water() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters