From d93f35701f95656d50c8f40a15f70c2779f714fc Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 25 Oct 2022 17:24:38 +1300 Subject: [PATCH] Send manufacturer name via API (#3938) --- esphome/components/api/api.proto | 2 ++ esphome/components/api/api_connection.cpp | 5 +++++ esphome/components/api/api_pb2.cpp | 9 +++++++++ esphome/components/api/api_pb2.h | 1 + 4 files changed, 17 insertions(+) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index a8e45e1ea6..5df35f7978 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -204,6 +204,8 @@ message DeviceInfoResponse { uint32 webserver_port = 10; uint32 bluetooth_proxy_version = 11; + + string manufacturer = 12; } message ListEntitiesRequest { diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 1dbf0abec4..5227750cc0 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -932,6 +932,11 @@ DeviceInfoResponse APIConnection::device_info(const DeviceInfoRequest &msg) { resp.mac_address = get_mac_address_pretty(); resp.esphome_version = ESPHOME_VERSION; resp.compilation_time = App.get_compilation_time(); +#if defined(USE_ESP8266) || defined(USE_ESP32) + resp.manufacturer = "Espressif"; +#elif defined(USE_RP2040) + resp.manufacturer = "Raspberry Pi"; +#endif resp.model = ESPHOME_BOARD; #ifdef USE_DEEP_SLEEP resp.has_deep_sleep = deep_sleep::global_has_deep_sleep; diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 8cb244f1a1..03d09a0913 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -576,6 +576,10 @@ bool DeviceInfoResponse::decode_length(uint32_t field_id, ProtoLengthDelimited v this->project_version = value.as_string(); return true; } + case 12: { + this->manufacturer = value.as_string(); + return true; + } default: return false; } @@ -592,6 +596,7 @@ void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(9, this->project_version); buffer.encode_uint32(10, this->webserver_port); buffer.encode_uint32(11, this->bluetooth_proxy_version); + buffer.encode_string(12, this->manufacturer); } #ifdef HAS_PROTO_MESSAGE_DUMP void DeviceInfoResponse::dump_to(std::string &out) const { @@ -642,6 +647,10 @@ void DeviceInfoResponse::dump_to(std::string &out) const { sprintf(buffer, "%u", this->bluetooth_proxy_version); out.append(buffer); out.append("\n"); + + out.append(" manufacturer: "); + out.append("'").append(this->manufacturer).append("'"); + out.append("\n"); out.append("}"); } #endif diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index fb676f1cc8..2ca0853951 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -273,6 +273,7 @@ class DeviceInfoResponse : public ProtoMessage { std::string project_version{}; uint32_t webserver_port{0}; uint32_t bluetooth_proxy_version{0}; + std::string manufacturer{}; void encode(ProtoWriteBuffer buffer) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override;