Fix climate MQTT HA interop

Fixes https://github.com/esphome/issues/issues/494
This commit is contained in:
Otto Winter 2019-07-01 11:09:44 +02:00
parent 71ba4bc31c
commit 83095e8989
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E

View file

@ -141,7 +141,21 @@ std::string MQTTClimateComponent::friendly_name() const { return this->device_->
bool MQTTClimateComponent::publish_state_() { bool MQTTClimateComponent::publish_state_() {
auto traits = this->device_->get_traits(); auto traits = this->device_->get_traits();
// mode // 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; bool success = true;
if (!this->publish(this->get_mode_state_topic(), mode_s)) if (!this->publish(this->get_mode_state_topic(), mode_s))
success = false; success = false;