mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 06:58:11 +01:00
Fix MQTT availability option
This commit is contained in:
parent
f39cf52eae
commit
d249820bcd
2 changed files with 6 additions and 3 deletions
|
@ -547,7 +547,7 @@ MQTT_COMPONENT_SCHEMA = vol.Schema({
|
||||||
vol.Optional(CONF_RETAIN): boolean,
|
vol.Optional(CONF_RETAIN): boolean,
|
||||||
vol.Optional(CONF_DISCOVERY): boolean,
|
vol.Optional(CONF_DISCOVERY): boolean,
|
||||||
vol.Optional(CONF_STATE_TOPIC): publish_topic,
|
vol.Optional(CONF_STATE_TOPIC): publish_topic,
|
||||||
vol.Optional(CONF_AVAILABILITY): MQTT_COMPONENT_AVAILABILITY_SCHEMA,
|
vol.Optional(CONF_AVAILABILITY): vol.Any(None, MQTT_COMPONENT_AVAILABILITY_SCHEMA),
|
||||||
})
|
})
|
||||||
|
|
||||||
MQTT_COMMAND_COMPONENT_SCHEMA = MQTT_COMPONENT_SCHEMA.extend({
|
MQTT_COMMAND_COMPONENT_SCHEMA = MQTT_COMPONENT_SCHEMA.extend({
|
||||||
|
|
|
@ -604,8 +604,11 @@ def setup_mqtt_component(obj, config):
|
||||||
add(obj.set_custom_command_topic(config[CONF_COMMAND_TOPIC]))
|
add(obj.set_custom_command_topic(config[CONF_COMMAND_TOPIC]))
|
||||||
if CONF_AVAILABILITY in config:
|
if CONF_AVAILABILITY in config:
|
||||||
availability = config[CONF_AVAILABILITY]
|
availability = config[CONF_AVAILABILITY]
|
||||||
add(obj.set_availability(availability[CONF_TOPIC], availability[CONF_PAYLOAD_AVAILABLE],
|
if not availability:
|
||||||
availability[CONF_PAYLOAD_NOT_AVAILABLE]))
|
add(obj.disable_availability())
|
||||||
|
else:
|
||||||
|
add(obj.set_availability(availability[CONF_TOPIC], availability[CONF_PAYLOAD_AVAILABLE],
|
||||||
|
availability[CONF_PAYLOAD_NOT_AVAILABLE]))
|
||||||
|
|
||||||
|
|
||||||
# shlex's quote for Python 2.7
|
# shlex's quote for Python 2.7
|
||||||
|
|
Loading…
Reference in a new issue