mirror of
https://github.com/esphome/esphome.git
synced 2025-09-17 02:32:20 +01:00
This commit is contained in:
committed by
Jesse Hills
parent
c601494779
commit
ae158179bd
@@ -27,9 +27,6 @@ service APIConnection {
|
|||||||
rpc subscribe_logs (SubscribeLogsRequest) returns (void) {}
|
rpc subscribe_logs (SubscribeLogsRequest) returns (void) {}
|
||||||
rpc subscribe_homeassistant_services (SubscribeHomeassistantServicesRequest) returns (void) {}
|
rpc subscribe_homeassistant_services (SubscribeHomeassistantServicesRequest) returns (void) {}
|
||||||
rpc subscribe_home_assistant_states (SubscribeHomeAssistantStatesRequest) returns (void) {}
|
rpc subscribe_home_assistant_states (SubscribeHomeAssistantStatesRequest) returns (void) {}
|
||||||
rpc get_time (GetTimeRequest) returns (GetTimeResponse) {
|
|
||||||
option (needs_authentication) = false;
|
|
||||||
}
|
|
||||||
rpc execute_service (ExecuteServiceRequest) returns (void) {}
|
rpc execute_service (ExecuteServiceRequest) returns (void) {}
|
||||||
rpc noise_encryption_set_key (NoiseEncryptionSetKeyRequest) returns (NoiseEncryptionSetKeyResponse) {}
|
rpc noise_encryption_set_key (NoiseEncryptionSetKeyRequest) returns (NoiseEncryptionSetKeyResponse) {}
|
||||||
|
|
||||||
@@ -809,12 +806,12 @@ message HomeAssistantStateResponse {
|
|||||||
// ==================== IMPORT TIME ====================
|
// ==================== IMPORT TIME ====================
|
||||||
message GetTimeRequest {
|
message GetTimeRequest {
|
||||||
option (id) = 36;
|
option (id) = 36;
|
||||||
option (source) = SOURCE_BOTH;
|
option (source) = SOURCE_SERVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetTimeResponse {
|
message GetTimeResponse {
|
||||||
option (id) = 37;
|
option (id) = 37;
|
||||||
option (source) = SOURCE_BOTH;
|
option (source) = SOURCE_CLIENT;
|
||||||
option (no_delay) = true;
|
option (no_delay) = true;
|
||||||
|
|
||||||
fixed32 epoch_seconds = 1;
|
fixed32 epoch_seconds = 1;
|
||||||
|
@@ -1081,12 +1081,6 @@ void APIConnection::on_get_time_response(const GetTimeResponse &value) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool APIConnection::send_get_time_response(const GetTimeRequest &msg) {
|
|
||||||
GetTimeResponse resp;
|
|
||||||
resp.epoch_seconds = ::time(nullptr);
|
|
||||||
return this->send_message(resp, GetTimeResponse::MESSAGE_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_BLUETOOTH_PROXY
|
#ifdef USE_BLUETOOTH_PROXY
|
||||||
void APIConnection::subscribe_bluetooth_le_advertisements(const SubscribeBluetoothLEAdvertisementsRequest &msg) {
|
void APIConnection::subscribe_bluetooth_le_advertisements(const SubscribeBluetoothLEAdvertisementsRequest &msg) {
|
||||||
bluetooth_proxy::global_bluetooth_proxy->subscribe_api_connection(this, msg.flags);
|
bluetooth_proxy::global_bluetooth_proxy->subscribe_api_connection(this, msg.flags);
|
||||||
|
@@ -219,7 +219,6 @@ class APIConnection final : public APIServerConnection {
|
|||||||
#ifdef USE_API_HOMEASSISTANT_STATES
|
#ifdef USE_API_HOMEASSISTANT_STATES
|
||||||
void subscribe_home_assistant_states(const SubscribeHomeAssistantStatesRequest &msg) override;
|
void subscribe_home_assistant_states(const SubscribeHomeAssistantStatesRequest &msg) override;
|
||||||
#endif
|
#endif
|
||||||
bool send_get_time_response(const GetTimeRequest &msg) override;
|
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
void execute_service(const ExecuteServiceRequest &msg) override;
|
void execute_service(const ExecuteServiceRequest &msg) override;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -921,14 +921,6 @@ bool GetTimeResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void GetTimeResponse::encode(ProtoWriteBuffer buffer) const {
|
|
||||||
buffer.encode_fixed32(1, this->epoch_seconds);
|
|
||||||
buffer.encode_string(2, this->timezone_ref_);
|
|
||||||
}
|
|
||||||
void GetTimeResponse::calculate_size(ProtoSize &size) const {
|
|
||||||
size.add_fixed32(1, this->epoch_seconds);
|
|
||||||
size.add_length(1, this->timezone_ref_.size());
|
|
||||||
}
|
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
void ListEntitiesServicesArgument::encode(ProtoWriteBuffer buffer) const {
|
void ListEntitiesServicesArgument::encode(ProtoWriteBuffer buffer) const {
|
||||||
buffer.encode_string(1, this->name_ref_);
|
buffer.encode_string(1, this->name_ref_);
|
||||||
|
@@ -1180,10 +1180,6 @@ class GetTimeResponse final : public ProtoDecodableMessage {
|
|||||||
#endif
|
#endif
|
||||||
uint32_t epoch_seconds{0};
|
uint32_t epoch_seconds{0};
|
||||||
std::string timezone{};
|
std::string timezone{};
|
||||||
StringRef timezone_ref_{};
|
|
||||||
void set_timezone(const StringRef &ref) { this->timezone_ref_ = ref; }
|
|
||||||
void encode(ProtoWriteBuffer buffer) const override;
|
|
||||||
void calculate_size(ProtoSize &size) const override;
|
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
void dump_to(std::string &out) const override;
|
void dump_to(std::string &out) const override;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1113,13 +1113,7 @@ void GetTimeRequest::dump_to(std::string &out) const { out.append("GetTimeReques
|
|||||||
void GetTimeResponse::dump_to(std::string &out) const {
|
void GetTimeResponse::dump_to(std::string &out) const {
|
||||||
MessageDumpHelper helper(out, "GetTimeResponse");
|
MessageDumpHelper helper(out, "GetTimeResponse");
|
||||||
dump_field(out, "epoch_seconds", this->epoch_seconds);
|
dump_field(out, "epoch_seconds", this->epoch_seconds);
|
||||||
out.append(" timezone: ");
|
dump_field(out, "timezone", this->timezone);
|
||||||
if (!this->timezone_ref_.empty()) {
|
|
||||||
out.append("'").append(this->timezone_ref_.c_str()).append("'");
|
|
||||||
} else {
|
|
||||||
out.append("'").append(this->timezone).append("'");
|
|
||||||
}
|
|
||||||
out.append("\n");
|
|
||||||
}
|
}
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
void ListEntitiesServicesArgument::dump_to(std::string &out) const {
|
void ListEntitiesServicesArgument::dump_to(std::string &out) const {
|
||||||
|
@@ -160,15 +160,6 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case GetTimeRequest::MESSAGE_TYPE: {
|
|
||||||
GetTimeRequest msg;
|
|
||||||
// Empty message: no decode needed
|
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
|
||||||
ESP_LOGVV(TAG, "on_get_time_request: %s", msg.dump().c_str());
|
|
||||||
#endif
|
|
||||||
this->on_get_time_request(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GetTimeResponse::MESSAGE_TYPE: {
|
case GetTimeResponse::MESSAGE_TYPE: {
|
||||||
GetTimeResponse msg;
|
GetTimeResponse msg;
|
||||||
msg.decode(msg_data, msg_size);
|
msg.decode(msg_data, msg_size);
|
||||||
@@ -656,11 +647,6 @@ void APIServerConnection::on_subscribe_home_assistant_states_request(const Subsc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
void APIServerConnection::on_get_time_request(const GetTimeRequest &msg) {
|
|
||||||
if (this->check_connection_setup_() && !this->send_get_time_response(msg)) {
|
|
||||||
this->on_fatal_error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
void APIServerConnection::on_execute_service_request(const ExecuteServiceRequest &msg) {
|
void APIServerConnection::on_execute_service_request(const ExecuteServiceRequest &msg) {
|
||||||
if (this->check_authenticated_()) {
|
if (this->check_authenticated_()) {
|
||||||
|
@@ -71,7 +71,7 @@ class APIServerConnectionBase : public ProtoService {
|
|||||||
#ifdef USE_API_HOMEASSISTANT_STATES
|
#ifdef USE_API_HOMEASSISTANT_STATES
|
||||||
virtual void on_home_assistant_state_response(const HomeAssistantStateResponse &value){};
|
virtual void on_home_assistant_state_response(const HomeAssistantStateResponse &value){};
|
||||||
#endif
|
#endif
|
||||||
virtual void on_get_time_request(const GetTimeRequest &value){};
|
|
||||||
virtual void on_get_time_response(const GetTimeResponse &value){};
|
virtual void on_get_time_response(const GetTimeResponse &value){};
|
||||||
|
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
@@ -226,7 +226,6 @@ class APIServerConnection : public APIServerConnectionBase {
|
|||||||
#ifdef USE_API_HOMEASSISTANT_STATES
|
#ifdef USE_API_HOMEASSISTANT_STATES
|
||||||
virtual void subscribe_home_assistant_states(const SubscribeHomeAssistantStatesRequest &msg) = 0;
|
virtual void subscribe_home_assistant_states(const SubscribeHomeAssistantStatesRequest &msg) = 0;
|
||||||
#endif
|
#endif
|
||||||
virtual bool send_get_time_response(const GetTimeRequest &msg) = 0;
|
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
virtual void execute_service(const ExecuteServiceRequest &msg) = 0;
|
virtual void execute_service(const ExecuteServiceRequest &msg) = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -348,7 +347,6 @@ class APIServerConnection : public APIServerConnectionBase {
|
|||||||
#ifdef USE_API_HOMEASSISTANT_STATES
|
#ifdef USE_API_HOMEASSISTANT_STATES
|
||||||
void on_subscribe_home_assistant_states_request(const SubscribeHomeAssistantStatesRequest &msg) override;
|
void on_subscribe_home_assistant_states_request(const SubscribeHomeAssistantStatesRequest &msg) override;
|
||||||
#endif
|
#endif
|
||||||
void on_get_time_request(const GetTimeRequest &msg) override;
|
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
void on_execute_service_request(const ExecuteServiceRequest &msg) override;
|
void on_execute_service_request(const ExecuteServiceRequest &msg) override;
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user