Add set_central_heating_ovrd service to opentherm_gw (#34425)

* Add set_central_heating_ovrd service to opentherm_gw

* Use await instead of async_create_task

Use await instead of async_create_task as per review.

Co-authored-by: J. Nick Koston <nick@koston.org>

* Use boolean values for service call to opentherm_gw.set_central_heating_ovrd

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
mvn23 2020-07-23 20:24:17 +02:00 committed by GitHub
parent 98a8ce0555
commit 6652af5cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
from .const import (
ATTR_CH_OVRD,
ATTR_DHW_OVRD,
ATTR_GW_ID,
ATTR_LEVEL,
@ -39,6 +40,7 @@ from .const import (
DATA_OPENTHERM_GW,
DOMAIN,
SERVICE_RESET_GATEWAY,
SERVICE_SET_CH_OVRD,
SERVICE_SET_CLOCK,
SERVICE_SET_CONTROL_SETPOINT,
SERVICE_SET_GPIO_MODE,
@ -127,6 +129,14 @@ def register_services(hass):
)
}
)
service_set_central_heating_ovrd_schema = vol.Schema(
{
vol.Required(ATTR_GW_ID): vol.All(
cv.string, vol.In(hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS])
),
vol.Required(ATTR_CH_OVRD): cv.boolean,
}
)
service_set_clock_schema = vol.Schema(
{
vol.Required(ATTR_GW_ID): vol.All(
@ -235,6 +245,18 @@ def register_services(hass):
DOMAIN, SERVICE_RESET_GATEWAY, reset_gateway, service_reset_schema
)
async def set_ch_ovrd(call):
"""Set the central heating override on the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
await gw_dev.gateway.set_ch_enable_bit(1 if call.data[ATTR_CH_OVRD] else 0)
hass.services.async_register(
DOMAIN,
SERVICE_SET_CH_OVRD,
set_ch_ovrd,
service_set_central_heating_ovrd_schema,
)
async def set_control_setpoint(call):
"""Set the control setpoint on the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]

View File

@ -12,6 +12,7 @@ from homeassistant.const import (
ATTR_GW_ID = "gateway_id"
ATTR_LEVEL = "level"
ATTR_DHW_OVRD = "dhw_override"
ATTR_CH_OVRD = "ch_override"
CONF_CLIMATE = "climate"
CONF_FLOOR_TEMP = "floor_temperature"
@ -27,6 +28,7 @@ DEVICE_CLASS_PROBLEM = "problem"
DOMAIN = "opentherm_gw"
SERVICE_RESET_GATEWAY = "reset_gateway"
SERVICE_SET_CH_OVRD = "set_central_heating_ovrd"
SERVICE_SET_CLOCK = "set_clock"
SERVICE_SET_CONTROL_SETPOINT = "set_control_setpoint"
SERVICE_SET_HOT_WATER_SETPOINT = "set_hot_water_setpoint"

View File

@ -7,6 +7,22 @@ reset_gateway:
description: The gateway_id of the OpenTherm Gateway.
example: "opentherm_gateway"
set_central_heating_ovrd:
description: >
Set the central heating override option on the gateway.
When overriding the control setpoint (via a set_control_setpoint service call with a value other than 0), the gateway automatically enables the central heating override to start heating.
This service can then be used to control the central heating override status.
To return control of the central heating to the thermostat, call the set_control_setpoint service with temperature value 0.
You will only need this if you are writing your own software thermostat.
fields:
gateway_id:
description: The gateway_id of the OpenTherm Gateway.
example: "opentherm_gateway"
ch_override:
description: >
The desired boolean value for the central heating override.
example: "on"
set_clock:
description: Set the clock and day of the week on the connected thermostat.
fields: