From 83095e8989aab44962c58849e2ff0d0006bc5534 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Mon, 1 Jul 2019 11:09:44 +0200 Subject: [PATCH] Fix climate MQTT HA interop Fixes https://github.com/esphome/issues/issues/494 --- esphome/components/mqtt/mqtt_climate.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/esphome/components/mqtt/mqtt_climate.cpp b/esphome/components/mqtt/mqtt_climate.cpp index 8085fbf0f2..48b470cfb2 100644 --- a/esphome/components/mqtt/mqtt_climate.cpp +++ b/esphome/components/mqtt/mqtt_climate.cpp @@ -141,7 +141,21 @@ std::string MQTTClimateComponent::friendly_name() const { return this->device_-> bool MQTTClimateComponent::publish_state_() { auto traits = this->device_->get_traits(); // mode - const char *mode_s = climate_mode_to_string(this->device_->mode); + const char *mode_s = ""; + switch (this->device_->mode) { + case CLIMATE_MODE_OFF: + mode_s = "off"; + break; + case CLIMATE_MODE_AUTO: + mode_s = "auto"; + break; + case CLIMATE_MODE_COOL: + mode_s = "cool"; + break; + case CLIMATE_MODE_HEAT: + mode_s = "heat"; + break; + } bool success = true; if (!this->publish(this->get_mode_state_topic(), mode_s)) success = false;