How do you update climate: preset, fan_mode, etc without HA?

My attempts are as follows.

First attempt was using POST urls like:
http://bedroom-heatpump.lan/climate/bedroom_heatpump/set?fan_mode=AUTO

Unfortunately while esphome gives an http 200 code for that, it doesn’t do anything. Digging in the code we find that anything other than mode and temps aren’t implemented:
: https://esphome.io/api/web__server_8cpp_source.html line 818

 void WebServer::handle_climate_request(AsyncWebServerRequest *request, const UrlMatch &match) {
   for (auto *obj : App.get_climates()) {
     if (obj->get_object_id() != match.id)
       continue;
 
     if (request->method() == HTTP_GET) {
       std::string data = this->climate_json(obj, DETAIL_STATE);
       request->send(200, "application/json", data.c_str());
       return;
     }
 
     if (match.method != "set") {
       request->send(404);
       return;
     }
 
     auto call = obj->make_call();
 
     if (request->hasParam("mode")) {
       String mode = request->getParam("mode")->value();
       call.set_mode(mode.c_str());
     }
 
     if (request->hasParam("target_temperature_high")) {
       String value = request->getParam("target_temperature_high")->value();
       optional<float> value_f = parse_number<float>(value.c_str());
       if (value_f.has_value())
         call.set_target_temperature_high(*value_f);
     }
 
     if (request->hasParam("target_temperature_low")) {
       String value = request->getParam("target_temperature_low")->value();
       optional<float> value_f = parse_number<float>(value.c_str());
       if (value_f.has_value())
         call.set_target_temperature_low(*value_f);
     }
 
     if (request->hasParam("target_temperature")) {
       String value = request->getParam("target_temperature")->value();
       optional<float> value_f = parse_number<float>(value.c_str());
       if (value_f.has_value())
         call.set_target_temperature(*value_f);
     }
 
     this->schedule_([call]() mutable { call.perform(); });
     request->send(200);
     return;
   }
   request->send(404);
 }

My next attempt was using a text input as a proxy. Basically use the text input and have lambda process the values submitted through the text input, That ran into the problem of discovering there are no text inputs for Esphome. Inputs that might take a string input like a select process the value and error out before an lambdas get a chance to do magic.

Looked at updating the values through the Native API. Used protbufc to generate the JS files from the api.proto file but they were massive, and I don’t think I’d have much luck shrinking it down, nor porting it to a browser environment. Tried rolling my own, but couldn’t get past the greeting part of the the protocol.

Needless to say a lot of trouble for a big nada, but I learned a lot.

Any other avenues I should look at? Planning to just make surrogate selects that control the other climate controls through lambda, but was hoping for a direct approach.

Have you tried with aioesphomeapi?

1 Like

That’s a interesting project. Thanks for the suggestion. I’m hoping for something I could run in a browser. Trying to make it so I can use an old cellphone as a thermostat. Wanting To set it up so Home Assistant is a nice to have, but if the router eaten by an alligator, the Home Assistant Pi is ran over by a bus or similar, everything keeps going on as normal.

I could easily run a Python environment on an old phone. Something to play around with.

Have you just tried the web browser interface? Web Server Component — ESPHome - I don’t know how user friendly the web ui is for a esphome climate component.

I have. It’s what started this project. The interface can be fixed. You can get the controls and states by reading http://{device-host-address-here}/events as a GET request.

Then it’s just a matter of writing your own JS to process these into web controls. You can make the page it displays look pretty fancy and polished if you’re handy with JS and CSS. Further as long as you keep your JS and CSS files small enough, the device it’s self can host them.

The problem I’m running into is unfortunately the climate controls from the web_server component are limited. You can set the temp, mode and that’s it. You can’t set presets or fan/blower speed, which is what I’m interested in adding. Further as I referenced above, the C code in the web_server component lacks code for controlling these things, so modifying the JS to add them doesn’t do much.

Hmmm, would you mind sharing your yaml? I wouldn’t mind replicating your setup and playing around.