Add transparent command to opentherm_gw (#116494)

This commit is contained in:
GraceGRD 2024-06-22 12:53:13 +02:00 committed by GitHub
parent 6e32a96ff3
commit 6a19808718
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 69 additions and 1 deletions

View File

@ -36,6 +36,8 @@ from .const import (
ATTR_DHW_OVRD,
ATTR_GW_ID,
ATTR_LEVEL,
ATTR_TRANSP_ARG,
ATTR_TRANSP_CMD,
CONF_CLIMATE,
CONF_FLOOR_TEMP,
CONF_PRECISION,
@ -46,6 +48,7 @@ from .const import (
DATA_OPENTHERM_GW,
DOMAIN,
SERVICE_RESET_GATEWAY,
SERVICE_SEND_TRANSP_CMD,
SERVICE_SET_CH_OVRD,
SERVICE_SET_CLOCK,
SERVICE_SET_CONTROL_SETPOINT,
@ -254,6 +257,19 @@ def register_services(hass: HomeAssistant) -> None:
),
}
)
service_send_transp_cmd_schema = vol.Schema(
{
vol.Required(ATTR_GW_ID): vol.All(
cv.string, vol.In(hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS])
),
vol.Required(ATTR_TRANSP_CMD): vol.All(
cv.string, vol.Length(min=2, max=2), vol.Coerce(str.upper)
),
vol.Required(ATTR_TRANSP_ARG): vol.All(
cv.string, vol.Length(min=1, max=12)
),
}
)
async def reset_gateway(call: ServiceCall) -> None:
"""Reset the OpenTherm Gateway."""
@ -377,6 +393,20 @@ def register_services(hass: HomeAssistant) -> None:
DOMAIN, SERVICE_SET_SB_TEMP, set_setback_temp, service_set_sb_temp_schema
)
async def send_transparent_cmd(call: ServiceCall) -> None:
"""Send a transparent OpenTherm Gateway command."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
transp_cmd = call.data[ATTR_TRANSP_CMD]
transp_arg = call.data[ATTR_TRANSP_ARG]
await gw_dev.gateway.send_transparent_command(transp_cmd, transp_arg)
hass.services.async_register(
DOMAIN,
SERVICE_SEND_TRANSP_CMD,
send_transparent_cmd,
service_send_transp_cmd_schema,
)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Cleanup and disconnect from gateway."""

View File

@ -19,6 +19,8 @@ ATTR_GW_ID = "gateway_id"
ATTR_LEVEL = "level"
ATTR_DHW_OVRD = "dhw_override"
ATTR_CH_OVRD = "ch_override"
ATTR_TRANSP_CMD = "transp_cmd"
ATTR_TRANSP_ARG = "transp_arg"
CONF_CLIMATE = "climate"
CONF_FLOOR_TEMP = "floor_temperature"
@ -45,6 +47,7 @@ SERVICE_SET_LED_MODE = "set_led_mode"
SERVICE_SET_MAX_MOD = "set_max_modulation"
SERVICE_SET_OAT = "set_outside_temperature"
SERVICE_SET_SB_TEMP = "set_setback_temperature"
SERVICE_SEND_TRANSP_CMD = "send_transparent_command"
TRANSLATE_SOURCE = {
gw_vars.BOILER: "Boiler",

View File

@ -10,6 +10,7 @@
"set_led_mode": "mdi:led-on",
"set_max_modulation": "mdi:thermometer-lines",
"set_outside_temperature": "mdi:thermometer-lines",
"set_setback_temperature": "mdi:thermometer-lines"
"set_setback_temperature": "mdi:thermometer-lines",
"send_transparent_command": "mdi:console"
}
}

View File

@ -181,3 +181,19 @@ set_setback_temperature:
max: 30
step: 0.1
unit_of_measurement: "°"
send_transparent_command:
fields:
gateway_id:
required: true
example: "opentherm_gateway"
selector:
text:
transp_cmd:
required: true
selector:
text:
transp_arg:
required: true
selector:
text:

View File

@ -190,6 +190,24 @@
"description": "The setback temperature to configure on the gateway."
}
}
},
"send_transparent_command": {
"name": "Send transparent command",
"description": "Sends custom otgw commands (https://otgw.tclcode.com/firmware.html) through a transparent interface.",
"fields": {
"gateway_id": {
"name": "[%key:component::opentherm_gw::services::reset_gateway::fields::gateway_id::name%]",
"description": "[%key:component::opentherm_gw::services::reset_gateway::fields::gateway_id::description%]"
},
"transp_cmd": {
"name": "Command",
"description": "The command to be sent to the OpenTherm Gateway."
},
"transp_arg": {
"name": "Argument",
"description": "The argument of the command to be sent to the OpenTherm Gateway."
}
}
}
}
}