This commit is contained in:
J. Nick Koston 2025-07-21 18:31:13 -10:00
parent d0511e118d
commit 8f201cdb7e
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View File

@ -84,16 +84,16 @@ void HomeassistantNumber::control(float value) {
this->publish_state(value); this->publish_state(value);
api::HomeassistantServiceResponse resp; api::HomeassistantServiceResponse resp;
resp.set_service("number.set_value", 17); resp.set_service(StringRef("number.set_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", 9); entity_id.set_key(StringRef("entity_id"));
entity_id.set_value(StringRef(this->entity_id_)); entity_id.set_value(StringRef(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", 5); entity_value.set_key(StringRef("value"));
std::string value_str = to_string(value); std::string value_str = to_string(value);
entity_value.set_value(StringRef(value_str)); entity_value.set_value(StringRef(value_str));

View File

@ -42,14 +42,14 @@ void HomeassistantSwitch::write_state(bool state) {
api::HomeassistantServiceResponse resp; api::HomeassistantServiceResponse resp;
if (state) { if (state) {
resp.set_service("homeassistant.turn_on", 22); resp.set_service(StringRef("homeassistant.turn_on"));
} else { } else {
resp.set_service("homeassistant.turn_off", 23); resp.set_service(StringRef("homeassistant.turn_off"));
} }
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", 9); entity_id_kv.set_key(StringRef("entity_id"));
entity_id_kv.set_value(StringRef(this->entity_id_)); entity_id_kv.set_value(StringRef(this->entity_id_));
api::global_api_server->send_homeassistant_service_call(resp); api::global_api_server->send_homeassistant_service_call(resp);