mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 15:18:16 +00:00
This would be much better
This commit is contained in:
parent
acfa00d769
commit
ea4694cdd1
@ -873,10 +873,9 @@ void PrometheusHandler::climate_value_row_(AsyncResponseStream *stream, climate:
|
|||||||
stream->print(F("\n"));
|
stream->print(F("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrometheusHandler::climate_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area,
|
void PrometheusHandler::climate_failed_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area,
|
||||||
std::string &node, std::string &friendly_name) {
|
std::string &node, std::string &friendly_name, std::string &category,
|
||||||
if (obj->is_internal() && !this->include_internal_)
|
bool is_failed_value) {
|
||||||
return;
|
|
||||||
stream->print(F("esphome_climate_failed{id=\""));
|
stream->print(F("esphome_climate_failed{id=\""));
|
||||||
stream->print(relabel_id_(obj).c_str());
|
stream->print(relabel_id_(obj).c_str());
|
||||||
add_area_label_(stream, area);
|
add_area_label_(stream, area);
|
||||||
@ -884,7 +883,22 @@ void PrometheusHandler::climate_row_(AsyncResponseStream *stream, climate::Clima
|
|||||||
add_friendly_name_label_(stream, friendly_name);
|
add_friendly_name_label_(stream, friendly_name);
|
||||||
stream->print(F("\",name=\""));
|
stream->print(F("\",name=\""));
|
||||||
stream->print(relabel_name_(obj).c_str());
|
stream->print(relabel_name_(obj).c_str());
|
||||||
stream->print(F("\"} 0\n"));
|
stream->print(F("\",category=\""));
|
||||||
|
stream->print(category.c_str());
|
||||||
|
stream->print(F("\"} "));
|
||||||
|
if (is_failed_value) {
|
||||||
|
stream->print(F("1.0"));
|
||||||
|
} else {
|
||||||
|
stream->print(F("0.0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->print(F("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrometheusHandler::climate_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area,
|
||||||
|
std::string &node, std::string &friendly_name) {
|
||||||
|
if (obj->is_internal() && !this->include_internal_)
|
||||||
|
return;
|
||||||
// Data itself
|
// Data itself
|
||||||
std::string climate_mode_category = "mode";
|
std::string climate_mode_category = "mode";
|
||||||
const auto *climate_mode_value = climate::climate_mode_to_string(obj->mode);
|
const auto *climate_mode_value = climate::climate_mode_to_string(obj->mode);
|
||||||
@ -902,10 +916,15 @@ void PrometheusHandler::climate_row_(AsyncResponseStream *stream, climate::Clima
|
|||||||
auto min_temp_value = value_accuracy_to_string(traits.get_visual_min_temperature(), target_accuracy);
|
auto min_temp_value = value_accuracy_to_string(traits.get_visual_min_temperature(), target_accuracy);
|
||||||
climate_value_row_(stream, obj, area, node, friendly_name, min_temp, min_temp_value);
|
climate_value_row_(stream, obj, area, node, friendly_name, min_temp, min_temp_value);
|
||||||
// now check optional traits
|
// now check optional traits
|
||||||
if (traits.get_supports_current_temperature() && !std::isnan(obj->current_temperature)) {
|
if (traits.get_supports_current_temperature()) {
|
||||||
std::string current_temp = "current_temperature";
|
std::string current_temp = "current_temperature";
|
||||||
auto current_temp_value = value_accuracy_to_string(obj->current_temperature, current_accuracy);
|
if (std::isnan(obj->current_temperature)) {
|
||||||
climate_value_row_(stream, obj, area, node, friendly_name, current_temp, current_temp_value);
|
climate_failed_row_(stream, obj, area, node, friendly_name, current_temp, true);
|
||||||
|
} else {
|
||||||
|
auto current_temp_value = value_accuracy_to_string(obj->current_temperature, current_accuracy);
|
||||||
|
climate_value_row_(stream, obj, area, node, friendly_name, current_temp, current_temp_value);
|
||||||
|
climate_failed_row_(stream, obj, area, node, friendly_name, current_temp, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (traits.get_supports_current_humidity() && !std::isnan(obj->current_humidity)) {
|
if (traits.get_supports_current_humidity() && !std::isnan(obj->current_humidity)) {
|
||||||
std::string current_humidity = "current_humidity";
|
std::string current_humidity = "current_humidity";
|
||||||
|
@ -178,6 +178,8 @@ class PrometheusHandler : public AsyncWebHandler, public Component {
|
|||||||
/// Return the climate state as prometheus data point
|
/// Return the climate state as prometheus data point
|
||||||
void climate_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area, std::string &node,
|
void climate_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area, std::string &node,
|
||||||
std::string &friendly_name);
|
std::string &friendly_name);
|
||||||
|
void climate_failed_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area, std::string &node,
|
||||||
|
std::string &friendly_name, std::string &category, bool is_failed_value);
|
||||||
void climate_setting_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area, std::string &node,
|
void climate_setting_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area, std::string &node,
|
||||||
std::string &friendly_name, std::string &setting, const LogString *setting_value);
|
std::string &friendly_name, std::string &setting, const LogString *setting_value);
|
||||||
void climate_value_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area, std::string &node,
|
void climate_value_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area, std::string &node,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user