mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
Don't fall back to the global availability topic if it is empty (#553)
Fixes esphome/issues#320
This commit is contained in:
parent
72a80f559a
commit
72218171b3
1 changed files with 7 additions and 5 deletions
|
@ -72,11 +72,13 @@ bool MQTTComponent::send_discovery_() {
|
||||||
root["command_topic"] = this->get_command_topic_();
|
root["command_topic"] = this->get_command_topic_();
|
||||||
|
|
||||||
if (this->availability_ == nullptr) {
|
if (this->availability_ == nullptr) {
|
||||||
root["availability_topic"] = global_mqtt_client->get_availability().topic;
|
if (!global_mqtt_client->get_availability().topic.empty()) {
|
||||||
if (global_mqtt_client->get_availability().payload_available != "online")
|
root["availability_topic"] = global_mqtt_client->get_availability().topic;
|
||||||
root["payload_available"] = global_mqtt_client->get_availability().payload_available;
|
if (global_mqtt_client->get_availability().payload_available != "online")
|
||||||
if (global_mqtt_client->get_availability().payload_not_available != "offline")
|
root["payload_available"] = global_mqtt_client->get_availability().payload_available;
|
||||||
root["payload_not_available"] = global_mqtt_client->get_availability().payload_not_available;
|
if (global_mqtt_client->get_availability().payload_not_available != "offline")
|
||||||
|
root["payload_not_available"] = global_mqtt_client->get_availability().payload_not_available;
|
||||||
|
}
|
||||||
} else if (!this->availability_->topic.empty()) {
|
} else if (!this->availability_->topic.empty()) {
|
||||||
root["availability_topic"] = this->availability_->topic;
|
root["availability_topic"] = this->availability_->topic;
|
||||||
if (this->availability_->payload_available != "online")
|
if (this->availability_->payload_available != "online")
|
||||||
|
|
Loading…
Reference in a new issue