mirror of
https://github.com/esphome/esphome.git
synced 2025-07-30 15:16:37 +00:00
Merge branch 'integration' into memory_api
This commit is contained in:
commit
cab11086ac
@ -93,14 +93,12 @@ void HomeassistantNumber::control(float value) {
|
|||||||
resp.data.emplace_back();
|
resp.data.emplace_back();
|
||||||
auto &entity_id = resp.data.back();
|
auto &entity_id = resp.data.back();
|
||||||
entity_id.set_key(ENTITY_ID_KEY);
|
entity_id.set_key(ENTITY_ID_KEY);
|
||||||
entity_id.set_value(StringRef(this->entity_id_));
|
entity_id.value = this->entity_id_;
|
||||||
|
|
||||||
resp.data.emplace_back();
|
resp.data.emplace_back();
|
||||||
auto &entity_value = resp.data.back();
|
auto &entity_value = resp.data.back();
|
||||||
entity_value.set_key(VALUE_KEY);
|
entity_value.set_key(VALUE_KEY);
|
||||||
// to_string() returns a temporary - must store it to avoid dangling reference
|
entity_value.value = to_string(value);
|
||||||
std::string value_str = to_string(value);
|
|
||||||
entity_value.set_value(StringRef(value_str));
|
|
||||||
|
|
||||||
api::global_api_server->send_homeassistant_service_call(resp);
|
api::global_api_server->send_homeassistant_service_call(resp);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ void HomeassistantSwitch::write_state(bool state) {
|
|||||||
resp.data.emplace_back();
|
resp.data.emplace_back();
|
||||||
auto &entity_id_kv = resp.data.back();
|
auto &entity_id_kv = resp.data.back();
|
||||||
entity_id_kv.set_key(ENTITY_ID_KEY);
|
entity_id_kv.set_key(ENTITY_ID_KEY);
|
||||||
entity_id_kv.set_value(StringRef(this->entity_id_));
|
entity_id_kv.value = this->entity_id_;
|
||||||
|
|
||||||
api::global_api_server->send_homeassistant_service_call(resp);
|
api::global_api_server->send_homeassistant_service_call(resp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user