diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 5d8d59b1f8..f31922a39b 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -70,8 +70,8 @@ service APIConnection { rpc alarm_control_panel_command (AlarmControlPanelCommandRequest) returns (void) {} - rpc zwave_proxy_read(ZWaveProxyReadRequest) returns (void) {} - rpc zwave_proxy_write(ZWaveProxyWriteRequest) returns (void) {} + rpc zwave_proxy_from_device(ZWaveProxyFromDeviceRequest) returns (void) {} + rpc zwave_proxy_to_device(ZWaveProxyToDeviceRequest) returns (void) {} } @@ -2284,14 +2284,14 @@ message UpdateCommandRequest { // ==================== Z-WAVE ==================== -message ZWaveProxyReadRequest { +message ZWaveProxyFromDeviceRequest { option (id) = 128; option (source) = SOURCE_CLIENT; option (ifdef) = "USE_ZWAVE_PROXY"; option (no_delay) = true; } -message ZWaveProxyReadResponse { +message ZWaveProxyFromDeviceResponse { option (id) = 129; option (source) = SOURCE_SERVER; option (ifdef) = "USE_ZWAVE_PROXY"; @@ -2300,7 +2300,7 @@ message ZWaveProxyReadResponse { string data = 1; } -message ZWaveProxyWriteRequest { +message ZWaveProxyToDeviceRequest { option (id) = 130; option (source) = SOURCE_CLIENT; option (ifdef) = "USE_ZWAVE_PROXY"; @@ -2309,7 +2309,7 @@ message ZWaveProxyWriteRequest { string data = 1; } -message ZWaveProxyWriteResponse { +message ZWaveProxyToDeviceResponse { option (id) = 131; option (source) = SOURCE_SERVER; option (ifdef) = "USE_ZWAVE_PROXY"; diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index fd4ef021e1..a17cba6c98 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1207,8 +1207,8 @@ void APIConnection::voice_assistant_set_configuration(const VoiceAssistantSetCon #endif #ifdef USE_ZWAVE_PROXY -void APIConnection::zwave_proxy_read(const ZWaveProxyReadRequest &msg) {} -void APIConnection::zwave_proxy_write(const ZWaveProxyWriteRequest &msg) { +void APIConnection::zwave_proxy_from_device(const ZWaveProxyFromDeviceRequest &msg) {} +void APIConnection::zwave_proxy_to_device(const ZWaveProxyToDeviceRequest &msg) { zwave_proxy::global_zwave_proxy->send_frame(msg.data); } #endif diff --git a/esphome/components/api/api_connection.h b/esphome/components/api/api_connection.h index 6eb964e482..f67ac7f422 100644 --- a/esphome/components/api/api_connection.h +++ b/esphome/components/api/api_connection.h @@ -172,8 +172,8 @@ class APIConnection final : public APIServerConnection { #endif #ifdef USE_ZWAVE_PROXY - void zwave_proxy_read(const ZWaveProxyReadRequest &msg) override; - void zwave_proxy_write(const ZWaveProxyWriteRequest &msg) override; + void zwave_proxy_from_device(const ZWaveProxyFromDeviceRequest &msg) override; + void zwave_proxy_to_device(const ZWaveProxyToDeviceRequest &msg) override; #endif #ifdef USE_ALARM_CONTROL_PANEL diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 2154de05b9..c93f779fee 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -3008,9 +3008,9 @@ bool UpdateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { } #endif #ifdef USE_ZWAVE_PROXY -void ZWaveProxyReadResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->data_ref_); } -void ZWaveProxyReadResponse::calculate_size(ProtoSize &size) const { size.add_length(1, this->data_ref_.size()); } -bool ZWaveProxyWriteRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { +void ZWaveProxyFromDeviceResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->data_ref_); } +void ZWaveProxyFromDeviceResponse::calculate_size(ProtoSize &size) const { size.add_length(1, this->data_ref_.size()); } +bool ZWaveProxyToDeviceRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: this->data = value.as_string(); diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 5712c139e2..c6ef5c3c4c 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -2914,12 +2914,12 @@ class UpdateCommandRequest final : public CommandProtoMessage { }; #endif #ifdef USE_ZWAVE_PROXY -class ZWaveProxyReadRequest final : public ProtoMessage { +class ZWaveProxyFromDeviceRequest final : public ProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 128; static constexpr uint8_t ESTIMATED_SIZE = 0; #ifdef HAS_PROTO_MESSAGE_DUMP - const char *message_name() const override { return "z_wave_proxy_read_request"; } + const char *message_name() const override { return "z_wave_proxy_from_device_request"; } #endif #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; @@ -2927,12 +2927,12 @@ class ZWaveProxyReadRequest final : public ProtoMessage { protected: }; -class ZWaveProxyReadResponse final : public ProtoMessage { +class ZWaveProxyFromDeviceResponse final : public ProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 129; static constexpr uint8_t ESTIMATED_SIZE = 9; #ifdef HAS_PROTO_MESSAGE_DUMP - const char *message_name() const override { return "z_wave_proxy_read_response"; } + const char *message_name() const override { return "z_wave_proxy_from_device_response"; } #endif StringRef data_ref_{}; void set_data(const StringRef &ref) { this->data_ref_ = ref; } @@ -2944,12 +2944,12 @@ class ZWaveProxyReadResponse final : public ProtoMessage { protected: }; -class ZWaveProxyWriteRequest final : public ProtoDecodableMessage { +class ZWaveProxyToDeviceRequest final : public ProtoDecodableMessage { public: static constexpr uint8_t MESSAGE_TYPE = 130; static constexpr uint8_t ESTIMATED_SIZE = 9; #ifdef HAS_PROTO_MESSAGE_DUMP - const char *message_name() const override { return "z_wave_proxy_write_request"; } + const char *message_name() const override { return "z_wave_proxy_to_device_request"; } #endif std::string data{}; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -2959,12 +2959,12 @@ class ZWaveProxyWriteRequest final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; }; -class ZWaveProxyWriteResponse final : public ProtoMessage { +class ZWaveProxyToDeviceResponse final : public ProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 131; static constexpr uint8_t ESTIMATED_SIZE = 0; #ifdef HAS_PROTO_MESSAGE_DUMP - const char *message_name() const override { return "z_wave_proxy_write_response"; } + const char *message_name() const override { return "z_wave_proxy_to_device_response"; } #endif #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 660852423b..982d410c53 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -2101,10 +2101,10 @@ void UpdateCommandRequest::dump_to(std::string &out) const { } #endif #ifdef USE_ZWAVE_PROXY -void ZWaveProxyReadRequest::dump_to(std::string &out) const { out.append("ZWaveProxyReadRequest {}"); } -void ZWaveProxyReadResponse::dump_to(std::string &out) const { dump_field(out, "data", this->data_ref_); } -void ZWaveProxyWriteRequest::dump_to(std::string &out) const { dump_field(out, "data", this->data); } -void ZWaveProxyWriteResponse::dump_to(std::string &out) const { out.append("ZWaveProxyWriteResponse {}"); } +void ZWaveProxyFromDeviceRequest::dump_to(std::string &out) const { out.append("ZWaveProxyFromDeviceRequest {}"); } +void ZWaveProxyFromDeviceResponse::dump_to(std::string &out) const { dump_field(out, "data", this->data_ref_); } +void ZWaveProxyToDeviceRequest::dump_to(std::string &out) const { dump_field(out, "data", this->data); } +void ZWaveProxyToDeviceResponse::dump_to(std::string &out) const { out.append("ZWaveProxyToDeviceResponse {}"); } #endif } // namespace esphome::api diff --git a/esphome/components/api/api_pb2_service.cpp b/esphome/components/api/api_pb2_service.cpp index a85150285f..d997a032e4 100644 --- a/esphome/components/api/api_pb2_service.cpp +++ b/esphome/components/api/api_pb2_service.cpp @@ -597,24 +597,24 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type, } #endif #ifdef USE_ZWAVE_PROXY - case ZWaveProxyReadRequest::MESSAGE_TYPE: { - ZWaveProxyReadRequest msg; + case ZWaveProxyFromDeviceRequest::MESSAGE_TYPE: { + ZWaveProxyFromDeviceRequest msg; // Empty message: no decode needed #ifdef HAS_PROTO_MESSAGE_DUMP - ESP_LOGVV(TAG, "on_z_wave_proxy_read_request: %s", msg.dump().c_str()); + ESP_LOGVV(TAG, "on_z_wave_proxy_from_device_request: %s", msg.dump().c_str()); #endif - this->on_z_wave_proxy_read_request(msg); + this->on_z_wave_proxy_from_device_request(msg); break; } #endif #ifdef USE_ZWAVE_PROXY - case ZWaveProxyWriteRequest::MESSAGE_TYPE: { - ZWaveProxyWriteRequest msg; + case ZWaveProxyToDeviceRequest::MESSAGE_TYPE: { + ZWaveProxyToDeviceRequest msg; msg.decode(msg_data, msg_size); #ifdef HAS_PROTO_MESSAGE_DUMP - ESP_LOGVV(TAG, "on_z_wave_proxy_write_request: %s", msg.dump().c_str()); + ESP_LOGVV(TAG, "on_z_wave_proxy_to_device_request: %s", msg.dump().c_str()); #endif - this->on_z_wave_proxy_write_request(msg); + this->on_z_wave_proxy_to_device_request(msg); break; } #endif @@ -932,16 +932,16 @@ void APIServerConnection::on_alarm_control_panel_command_request(const AlarmCont } #endif #ifdef USE_ZWAVE_PROXY -void APIServerConnection::on_z_wave_proxy_read_request(const ZWaveProxyReadRequest &msg) { +void APIServerConnection::on_z_wave_proxy_from_device_request(const ZWaveProxyFromDeviceRequest &msg) { if (this->check_authenticated_()) { - this->zwave_proxy_read(msg); + this->zwave_proxy_from_device(msg); } } #endif #ifdef USE_ZWAVE_PROXY -void APIServerConnection::on_z_wave_proxy_write_request(const ZWaveProxyWriteRequest &msg) { +void APIServerConnection::on_z_wave_proxy_to_device_request(const ZWaveProxyToDeviceRequest &msg) { if (this->check_authenticated_()) { - this->zwave_proxy_write(msg); + this->zwave_proxy_to_device(msg); } } #endif diff --git a/esphome/components/api/api_pb2_service.h b/esphome/components/api/api_pb2_service.h index 05009a368a..1d0952ec8e 100644 --- a/esphome/components/api/api_pb2_service.h +++ b/esphome/components/api/api_pb2_service.h @@ -207,11 +207,11 @@ class APIServerConnectionBase : public ProtoService { virtual void on_update_command_request(const UpdateCommandRequest &value){}; #endif #ifdef USE_ZWAVE_PROXY - virtual void on_z_wave_proxy_read_request(const ZWaveProxyReadRequest &value){}; + virtual void on_z_wave_proxy_from_device_request(const ZWaveProxyFromDeviceRequest &value){}; #endif #ifdef USE_ZWAVE_PROXY - virtual void on_z_wave_proxy_write_request(const ZWaveProxyWriteRequest &value){}; + virtual void on_z_wave_proxy_to_device_request(const ZWaveProxyToDeviceRequest &value){}; #endif protected: @@ -342,10 +342,10 @@ class APIServerConnection : public APIServerConnectionBase { virtual void alarm_control_panel_command(const AlarmControlPanelCommandRequest &msg) = 0; #endif #ifdef USE_ZWAVE_PROXY - virtual void zwave_proxy_read(const ZWaveProxyReadRequest &msg) = 0; + virtual void zwave_proxy_from_device(const ZWaveProxyFromDeviceRequest &msg) = 0; #endif #ifdef USE_ZWAVE_PROXY - virtual void zwave_proxy_write(const ZWaveProxyWriteRequest &msg) = 0; + virtual void zwave_proxy_to_device(const ZWaveProxyToDeviceRequest &msg) = 0; #endif protected: void on_hello_request(const HelloRequest &msg) override; @@ -470,10 +470,10 @@ class APIServerConnection : public APIServerConnectionBase { void on_alarm_control_panel_command_request(const AlarmControlPanelCommandRequest &msg) override; #endif #ifdef USE_ZWAVE_PROXY - void on_z_wave_proxy_read_request(const ZWaveProxyReadRequest &msg) override; + void on_z_wave_proxy_from_device_request(const ZWaveProxyFromDeviceRequest &msg) override; #endif #ifdef USE_ZWAVE_PROXY - void on_z_wave_proxy_write_request(const ZWaveProxyWriteRequest &msg) override; + void on_z_wave_proxy_to_device_request(const ZWaveProxyToDeviceRequest &msg) override; #endif };