diff --git a/src/display.cpp b/src/display.cpp index a40ed8c..31cfa0f 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -640,7 +640,23 @@ void CUDDisplay::handle_ac_change(uint8_t mode, uint8_t fan_speed, uint8_t tempe void CUDDisplay::handle_ac_sensor(float temperature, float humidity) { - // Not needed for now + // Is the temperature valid? + // A temperature of -999.0 means the sensor is not connected + ESP_LOGV("CUD Display", "AC Sensor Temperature: %f", temperature); + if (temperature == -999.0) + { + // If the temperature is not valid, Send NA to the display + this->takeSerialMutex(); + this->displayAdapter->printf("%s.txt=\"NA\"", LCD_DASHBOARD_ELEMENT_NAME_ROOM_TEMPERATURE); + this->sendStopBytes(); + this->giveSerialMutex(); + return; + } + // Temperature is valid, send it to the display + this->takeSerialMutex(); + this->displayAdapter->printf("%s.txt=\"%d\"", LCD_DASHBOARD_ELEMENT_NAME_ROOM_TEMPERATURE, (int)temperature); + this->sendStopBytes(); + this->giveSerialMutex(); } void CUDDisplay::handle_mqtt_connected()