1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

Command retain option for MQTT component (#3078)

This commit is contained in:
VitaliyKurokhtin
2022-01-23 00:05:37 -08:00
committed by GitHub
parent 97681d142e
commit 8187a4bce9
7 changed files with 304 additions and 289 deletions

View File

@@ -11,6 +11,7 @@ from esphome.const import (
CONF_BROKER,
CONF_CLIENT_ID,
CONF_COMMAND_TOPIC,
CONF_COMMAND_RETAIN,
CONF_DISCOVERY,
CONF_DISCOVERY_PREFIX,
CONF_DISCOVERY_RETAIN,
@@ -392,6 +393,8 @@ async def register_mqtt_component(var, config):
cg.add(var.set_custom_state_topic(config[CONF_STATE_TOPIC]))
if CONF_COMMAND_TOPIC in config:
cg.add(var.set_custom_command_topic(config[CONF_COMMAND_TOPIC]))
if CONF_COMMAND_RETAIN in config:
cg.add(var.set_command_retain(config[CONF_COMMAND_RETAIN]))
if CONF_AVAILABILITY in config:
availability = config[CONF_AVAILABILITY]
if not availability: