mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 09:23:17 -04:00
Add hot water push functionality to opentherm_gw (#182299)
This commit is contained in:
@@ -18,6 +18,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import OpenThermGatewayHub
|
||||
from .const import (
|
||||
BOILER_DEVICE_DESCRIPTION,
|
||||
DATA_GATEWAYS,
|
||||
DATA_OPENTHERM_GW,
|
||||
GATEWAY_DEVICE_DESCRIPTION,
|
||||
@@ -42,10 +43,17 @@ BUTTON_DESCRIPTIONS: tuple[OpenThermButtonEntityDescription, ...] = (
|
||||
device_description=THERMOSTAT_DEVICE_DESCRIPTION,
|
||||
action=lambda hub: hub.set_room_setpoint(0),
|
||||
),
|
||||
OpenThermButtonEntityDescription(
|
||||
key="hot_water_push",
|
||||
translation_key="hot_water_push",
|
||||
device_description=BOILER_DEVICE_DESCRIPTION,
|
||||
action=lambda hub: hub.gateway.set_hot_water_ovrd("P"),
|
||||
),
|
||||
OpenThermButtonEntityDescription(
|
||||
key="restart_button",
|
||||
device_class=ButtonDeviceClass.RESTART,
|
||||
device_description=GATEWAY_DEVICE_DESCRIPTION,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
action=lambda hub: hub.gateway.set_mode(gw_vars.OTGW_MODE_RESET),
|
||||
),
|
||||
)
|
||||
@@ -67,7 +75,6 @@ async def async_setup_entry(
|
||||
class OpenThermButton(OpenThermEntity, ButtonEntity):
|
||||
"""Representation of an OpenTherm button."""
|
||||
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
entity_description: OpenThermButtonEntityDescription
|
||||
|
||||
@override
|
||||
|
||||
@@ -160,6 +160,9 @@
|
||||
"button": {
|
||||
"cancel_room_setpoint_override": {
|
||||
"name": "Cancel room setpoint override"
|
||||
},
|
||||
"hot_water_push": {
|
||||
"name": "Heat hot water once"
|
||||
}
|
||||
},
|
||||
"select": {
|
||||
|
||||
@@ -50,6 +50,40 @@ async def test_cancel_room_setpoint_override_button(
|
||||
mock_pyotgw.return_value.set_target_temp.assert_awaited_once_with(0, True)
|
||||
|
||||
|
||||
async def test_hot_water_push_button(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_pyotgw: MagicMock,
|
||||
) -> None:
|
||||
"""Test hot water push button."""
|
||||
|
||||
mock_pyotgw.return_value.set_hot_water_ovrd = AsyncMock(return_value="P")
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
button_entity_id := entity_registry.async_get_entity_id(
|
||||
BUTTON_DOMAIN,
|
||||
DOMAIN,
|
||||
f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.BOILER}-hot_water_push",
|
||||
)
|
||||
) is not None
|
||||
|
||||
await hass.services.async_call(
|
||||
BUTTON_DOMAIN,
|
||||
SERVICE_PRESS,
|
||||
{
|
||||
ATTR_ENTITY_ID: button_entity_id,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mock_pyotgw.return_value.set_hot_water_ovrd.assert_awaited_once_with("P")
|
||||
|
||||
|
||||
async def test_restart_button(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
|
||||
Reference in New Issue
Block a user