Skip to content

Commit

Permalink
Add Tami4 integration boil water button (home-assistant#103400)
Browse files Browse the repository at this point in the history
* 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
Guy293 and joostlek authored Dec 31, 2023
1 parent 83b0934 commit 70e2ff3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@ omit =
homeassistant/components/tado/device_tracker.py
homeassistant/components/tado/sensor.py
homeassistant/components/tado/water_heater.py
homeassistant/components/tami4/button.py
homeassistant/components/tank_utility/sensor.py
homeassistant/components/tankerkoenig/__init__.py
homeassistant/components/tankerkoenig/binary_sensor.py
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tami4/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .const import API, CONF_REFRESH_TOKEN, COORDINATOR, DOMAIN
from .coordinator import Tami4EdgeWaterQualityCoordinator

PLATFORMS: list[Platform] = [Platform.SENSOR]
PLATFORMS: list[Platform] = [Platform.BUTTON, Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
42 changes: 42 additions & 0 deletions homeassistant/components/tami4/button.py
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()
5 changes: 5 additions & 0 deletions homeassistant/components/tami4/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"filter_litters_passed": {
"name": "Filter water passed"
}
},
"button": {
"boil_water": {
"name": "Boil water"
}
}
},
"config": {
Expand Down

0 comments on commit 70e2ff3

Please sign in to comment.