mirror of
https://github.com/esphome/esphome.git
synced 2025-04-15 07:10:33 +01:00
Trying again
This commit is contained in:
parent
d05f641dd0
commit
db0533cc1e
@ -89,6 +89,12 @@ void PrometheusHandler::handleRequest(AsyncWebServerRequest *req) {
|
|||||||
this->valve_row_(stream, obj, area, node, friendly_name);
|
this->valve_row_(stream, obj, area, node, friendly_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CLIMATE
|
||||||
|
this->climate_type_(stream);
|
||||||
|
for (auto *obj : App.get_climates())
|
||||||
|
this->climate_row_(stream, obj, area, node, friendly_name);
|
||||||
|
#endif
|
||||||
|
|
||||||
req->send(stream);
|
req->send(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,6 +830,40 @@ void PrometheusHandler::valve_row_(AsyncResponseStream *stream, valve::Valve *ob
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CLIMATE
|
||||||
|
void PrometheusHandler::climate_type_(AsyncResponseStream *stream) {
|
||||||
|
stream->print(F("#TYPE esphome_climate_operation gauge\n"));
|
||||||
|
stream->print(F("#TYPE esphome_climate_failed gauge\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;
|
||||||
|
stream->print(F("esphome_climate_failed{id=\""));
|
||||||
|
stream->print(relabel_id_(obj).c_str());
|
||||||
|
add_area_label_(stream, area);
|
||||||
|
add_node_label_(stream, node);
|
||||||
|
add_friendly_name_label_(stream, friendly_name);
|
||||||
|
stream->print(F("\",name=\""));
|
||||||
|
stream->print(relabel_name_(obj).c_str());
|
||||||
|
stream->print(F("\"} 0\n"));
|
||||||
|
// Data itself
|
||||||
|
stream->print(F("esphome_climate_operation{id=\""));
|
||||||
|
stream->print(relabel_id_(obj).c_str());
|
||||||
|
add_area_label_(stream, area);
|
||||||
|
add_node_label_(stream, node);
|
||||||
|
add_friendly_name_label_(stream, friendly_name);
|
||||||
|
stream->print(F("\",name=\""));
|
||||||
|
stream->print(relabel_name_(obj).c_str());
|
||||||
|
stream->print(F("\",operation=\""));
|
||||||
|
// stream->print(valve::valve_operation_to_str(obj->current_operation));
|
||||||
|
stream->print(F("\"} "));
|
||||||
|
stream->print(F("1.0"));
|
||||||
|
stream->print(F("\n"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace prometheus
|
} // namespace prometheus
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
#endif
|
#endif
|
||||||
|
@ -169,6 +169,14 @@ class PrometheusHandler : public AsyncWebHandler, public Component {
|
|||||||
std::string &friendly_name);
|
std::string &friendly_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CLIMATE
|
||||||
|
/// Return the type for prometheus
|
||||||
|
void climate_type_(AsyncResponseStream *stream);
|
||||||
|
/// Return the climate state as prometheus data point
|
||||||
|
void climate_row_(AsyncResponseStream *stream, climate::Climate *obj, std::string &area, std::string &node,
|
||||||
|
std::string &friendly_name);
|
||||||
|
#endif
|
||||||
|
|
||||||
web_server_base::WebServerBase *base_;
|
web_server_base::WebServerBase *base_;
|
||||||
bool include_internal_{false};
|
bool include_internal_{false};
|
||||||
std::map<EntityBase *, std::string> relabel_map_id_;
|
std::map<EntityBase *, std::string> relabel_map_id_;
|
||||||
|
@ -129,6 +129,14 @@ valve:
|
|||||||
optimistic: true
|
optimistic: true
|
||||||
has_position: true
|
has_position: true
|
||||||
|
|
||||||
|
remote_transmitter:
|
||||||
|
pin: ${pin}
|
||||||
|
carrier_duty_percent: 50%
|
||||||
|
|
||||||
|
climate:
|
||||||
|
- platform: climate_ir_lg
|
||||||
|
name: LG Climate
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
include_internal: true
|
include_internal: true
|
||||||
relabel:
|
relabel:
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
substitutions:
|
||||||
|
pin: GPIO2
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
|
||||||
i2s_audio:
|
i2s_audio:
|
||||||
|
@ -1 +1,4 @@
|
|||||||
|
substitutions:
|
||||||
|
pin: GPIO2
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@ -1 +1,4 @@
|
|||||||
|
substitutions:
|
||||||
|
pin: GPIO2
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@ -1 +1,4 @@
|
|||||||
|
substitutions:
|
||||||
|
pin: GPIO2
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@ -1 +1,4 @@
|
|||||||
|
substitutions:
|
||||||
|
pin: GPIO5
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user