Add current_humidity to climate JSON when supported

Include current_humidity field in climate state JSON when the climate
device supports CLIMATE_SUPPORTS_CURRENT_HUMIDITY.
This commit is contained in:
Ryan Wagoner
2026-02-18 14:17:23 -05:00
parent 0cadca9c47
commit 16deb55acb

View File

@@ -1594,6 +1594,11 @@ std::string WebServer::climate_json_(climate::Climate *obj, JsonDetail start_con
? "NA"
: (value_accuracy_to_buf(temp_buf, obj->current_temperature, current_accuracy), temp_buf);
}
if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_HUMIDITY)) {
root[ESPHOME_F("current_humidity")] =
std::isnan(obj->current_humidity) ? "NA"
: (value_accuracy_to_buf(temp_buf, obj->current_humidity, 0), temp_buf);
}
if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE |
climate::CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE)) {
root[ESPHOME_F("target_temperature_low")] =