The latest esphome 2025.8.0 seems to have broken my lambda code that I used to turn on and off a Kasa plug (and worked 2 weeks ago)
esphome::api::HomeassistantServiceResponse resp; // Call the service via C
resp.service = "switch.turn_off";
esphome::api::HomeassistantServiceMap data;
data.key = "entity_id";
data.value = "${filter_plug_entity}";
resp.data.push_back(data);
id(ha_api).send_homeassistant_service_call(resp);
With error:
/config/esphome/Wen3417Remote.yaml: In lambda function:
/config/esphome/Wen3417Remote.yaml:496:16: error: 'class esphome::api::HomeassistantServiceResponse' has no member named 'service'; did you mean 'set_service'?
496 | resp.service = "switch.turn_off";
| ^~~~~~~
| set_service
/config/esphome/Wen3417Remote.yaml:498:16: error: 'class esphome::api::HomeassistantServiceMap' has no member named 'key'
498 | data.key = "entity_id";
| ^~~
I tried a newer approach like:
esphome::api::CustomAPIDevice api;
api.call_service("switch", "turn_off", {{"entity_id", "${filter_plug_entity}"}});
But that and variations gave errors like:
/config/esphome/Wen3417Remote.yaml: In lambda function:
/config/esphome/Wen3417Remote.yaml:496:15: error: 'class esphome::api::CustomAPIDevice' has no member named 'call_service'
496 | api.call_service("switch", "turn_off", {{"entity_id", "${filter_plug_entity}"}});
| ^~~~~~~~~~~~
Trying:
id(ha_api).call_service("switch.turn_off", {{"entity_id", "${filter_plug_entity}"}});
gave similar errors.
There must be a simple way to call a service from lambda code as that seems like a very basic thing to do but I can’t figure out how…
(NOTE: I know I could try to do this all in yaml, but I have a complex sequence of service calls and associated manipulations
that is simpler to do all in C)