Add "cancel room setpoint override" button to opentherm_gw (#132162)
parent
4daf6dd41d
commit
0ff2a0d66d
|
@ -16,7 +16,12 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import OpenThermGatewayHub
|
||||
from .const import DATA_GATEWAYS, DATA_OPENTHERM_GW, GATEWAY_DEVICE_DESCRIPTION
|
||||
from .const import (
|
||||
DATA_GATEWAYS,
|
||||
DATA_OPENTHERM_GW,
|
||||
GATEWAY_DEVICE_DESCRIPTION,
|
||||
THERMOSTAT_DEVICE_DESCRIPTION,
|
||||
)
|
||||
from .entity import OpenThermEntity, OpenThermEntityDescription
|
||||
|
||||
|
||||
|
@ -30,6 +35,12 @@ class OpenThermButtonEntityDescription(
|
|||
|
||||
|
||||
BUTTON_DESCRIPTIONS: tuple[OpenThermButtonEntityDescription, ...] = (
|
||||
OpenThermButtonEntityDescription(
|
||||
key="cancel_room_setpoint_override",
|
||||
translation_key="cancel_room_setpoint_override",
|
||||
device_description=THERMOSTAT_DEVICE_DESCRIPTION,
|
||||
action=lambda hub: hub.set_room_setpoint(0),
|
||||
),
|
||||
OpenThermButtonEntityDescription(
|
||||
key="restart_button",
|
||||
device_class=ButtonDeviceClass.RESTART,
|
||||
|
|
|
@ -158,6 +158,11 @@
|
|||
"name": "Programmed change has priority over override"
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
"cancel_room_setpoint_override": {
|
||||
"name": "Cancel room setpoint override"
|
||||
}
|
||||
},
|
||||
"select": {
|
||||
"gpio_mode_n": {
|
||||
"name": "GPIO {gpio_id} mode",
|
||||
|
|
|
@ -16,6 +16,40 @@ from .conftest import MINIMAL_STATUS
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_cancel_room_setpoint_override_button(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_pyotgw: MagicMock,
|
||||
) -> None:
|
||||
"""Test cancel room setpoint override button."""
|
||||
|
||||
mock_pyotgw.return_value.set_target_temp = AsyncMock(return_value=0)
|
||||
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,
|
||||
OPENTHERM_DOMAIN,
|
||||
f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.THERMOSTAT}-cancel_room_setpoint_override",
|
||||
)
|
||||
) 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_target_temp.assert_awaited_once_with(0, True)
|
||||
|
||||
|
||||
async def test_restart_button(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
|
|
Loading…
Reference in New Issue