Skip to content

Fix private C API usage by implementing CustomAPIDevice #55

@alkuzad

Description

@alkuzad

From the discussion on https://community.home-assistant.io/t/esphome-stability-too-much-breaking-changes-compared-to-tasmota/959500/20
some of the functionalities use private api and they should use public one, stable:

CustomAPIDevice instead of manually constructing Protobuf message

Bad - private usage:

api::HomeassistantServiceResponse resp;

resp.service = service;

resp.data.push_back(...);

send_homeassistant_service_call(resp);

Good - public API usage:

// This is stable public API

call_homeassistant_service("light.turn_on", {

{"entity_id", "light.my_light"},

{"brightness", "127"},

});

fire_homeassistant_event("esphome.something_happened", {

{"my_value", "500"},

});

CustomApiDevice:

https://github.com/esphome/esphome/blob/1f271e7c10e28596ff5002088b7ffae33feb4035/esphome/components/api/custom_api_device.h

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions