1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-19 03:32:20 +01:00

Merge remote-tracking branch 'upstream/dev' into zwave_proxy

This commit is contained in:
kbx81
2025-09-17 16:08:18 -05:00
14 changed files with 44 additions and 42 deletions

View File

@@ -212,7 +212,7 @@ def has_mqtt_logging() -> bool:
if CONF_TOPIC not in log_topic: if CONF_TOPIC not in log_topic:
return False return False
return log_topic[CONF_LEVEL] != "NONE" return log_topic.get(CONF_LEVEL, None) != "NONE"
def has_mqtt() -> bool: def has_mqtt() -> bool:

View File

@@ -7,7 +7,7 @@ service APIConnection {
option (needs_setup_connection) = false; option (needs_setup_connection) = false;
option (needs_authentication) = false; option (needs_authentication) = false;
} }
rpc connect (ConnectRequest) returns (ConnectResponse) { rpc authenticate (AuthenticationRequest) returns (AuthenticationResponse) {
option (needs_setup_connection) = false; option (needs_setup_connection) = false;
option (needs_authentication) = false; option (needs_authentication) = false;
} }
@@ -132,7 +132,7 @@ message HelloResponse {
// Message sent at the beginning of each connection to authenticate the client // Message sent at the beginning of each connection to authenticate the client
// Can only be sent by the client and only at the beginning of the connection // Can only be sent by the client and only at the beginning of the connection
message ConnectRequest { message AuthenticationRequest {
option (id) = 3; option (id) = 3;
option (source) = SOURCE_CLIENT; option (source) = SOURCE_CLIENT;
option (no_delay) = true; option (no_delay) = true;
@@ -144,7 +144,7 @@ message ConnectRequest {
// Confirmation of successful connection. After this the connection is available for all traffic. // Confirmation of successful connection. After this the connection is available for all traffic.
// Can only be sent by the server and only at the beginning of the connection // Can only be sent by the server and only at the beginning of the connection
message ConnectResponse { message AuthenticationResponse {
option (id) = 4; option (id) = 4;
option (source) = SOURCE_SERVER; option (source) = SOURCE_SERVER;
option (no_delay) = true; option (no_delay) = true;

View File

@@ -1399,14 +1399,14 @@ bool APIConnection::send_hello_response(const HelloRequest &msg) {
return this->send_message(resp, HelloResponse::MESSAGE_TYPE); return this->send_message(resp, HelloResponse::MESSAGE_TYPE);
} }
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
bool APIConnection::send_connect_response(const ConnectRequest &msg) { bool APIConnection::send_authenticate_response(const AuthenticationRequest &msg) {
ConnectResponse resp; AuthenticationResponse resp;
// bool invalid_password = 1; // bool invalid_password = 1;
resp.invalid_password = !this->parent_->check_password(msg.password); resp.invalid_password = !this->parent_->check_password(msg.password);
if (!resp.invalid_password) { if (!resp.invalid_password) {
this->complete_authentication_(); this->complete_authentication_();
} }
return this->send_message(resp, ConnectResponse::MESSAGE_TYPE); return this->send_message(resp, AuthenticationResponse::MESSAGE_TYPE);
} }
#endif // USE_API_PASSWORD #endif // USE_API_PASSWORD

View File

@@ -203,7 +203,7 @@ class APIConnection final : public APIServerConnection {
#endif #endif
bool send_hello_response(const HelloRequest &msg) override; bool send_hello_response(const HelloRequest &msg) override;
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
bool send_connect_response(const ConnectRequest &msg) override; bool send_authenticate_response(const AuthenticationRequest &msg) override;
#endif #endif
bool send_disconnect_response(const DisconnectRequest &msg) override; bool send_disconnect_response(const DisconnectRequest &msg) override;
bool send_ping_response(const PingRequest &msg) override; bool send_ping_response(const PingRequest &msg) override;

View File

@@ -43,7 +43,7 @@ void HelloResponse::calculate_size(ProtoSize &size) const {
size.add_length(1, this->name_ref_.size()); size.add_length(1, this->name_ref_.size());
} }
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
bool ConnectRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { bool AuthenticationRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
switch (field_id) { switch (field_id) {
case 1: case 1:
this->password = value.as_string(); this->password = value.as_string();
@@ -53,8 +53,8 @@ bool ConnectRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value
} }
return true; return true;
} }
void ConnectResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->invalid_password); } void AuthenticationResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->invalid_password); }
void ConnectResponse::calculate_size(ProtoSize &size) const { size.add_bool(1, this->invalid_password); } void AuthenticationResponse::calculate_size(ProtoSize &size) const { size.add_bool(1, this->invalid_password); }
#endif #endif
#ifdef USE_AREAS #ifdef USE_AREAS
void AreaInfo::encode(ProtoWriteBuffer buffer) const { void AreaInfo::encode(ProtoWriteBuffer buffer) const {

View File

@@ -367,12 +367,12 @@ class HelloResponse final : public ProtoMessage {
protected: protected:
}; };
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
class ConnectRequest final : public ProtoDecodableMessage { class AuthenticationRequest final : public ProtoDecodableMessage {
public: public:
static constexpr uint8_t MESSAGE_TYPE = 3; static constexpr uint8_t MESSAGE_TYPE = 3;
static constexpr uint8_t ESTIMATED_SIZE = 9; static constexpr uint8_t ESTIMATED_SIZE = 9;
#ifdef HAS_PROTO_MESSAGE_DUMP #ifdef HAS_PROTO_MESSAGE_DUMP
const char *message_name() const override { return "connect_request"; } const char *message_name() const override { return "authentication_request"; }
#endif #endif
std::string password{}; std::string password{};
#ifdef HAS_PROTO_MESSAGE_DUMP #ifdef HAS_PROTO_MESSAGE_DUMP
@@ -382,12 +382,12 @@ class ConnectRequest final : public ProtoDecodableMessage {
protected: protected:
bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override;
}; };
class ConnectResponse final : public ProtoMessage { class AuthenticationResponse final : public ProtoMessage {
public: public:
static constexpr uint8_t MESSAGE_TYPE = 4; static constexpr uint8_t MESSAGE_TYPE = 4;
static constexpr uint8_t ESTIMATED_SIZE = 2; static constexpr uint8_t ESTIMATED_SIZE = 2;
#ifdef HAS_PROTO_MESSAGE_DUMP #ifdef HAS_PROTO_MESSAGE_DUMP
const char *message_name() const override { return "connect_response"; } const char *message_name() const override { return "authentication_response"; }
#endif #endif
bool invalid_password{false}; bool invalid_password{false};
void encode(ProtoWriteBuffer buffer) const override; void encode(ProtoWriteBuffer buffer) const override;

View File

@@ -682,8 +682,11 @@ void HelloResponse::dump_to(std::string &out) const {
dump_field(out, "name", this->name_ref_); dump_field(out, "name", this->name_ref_);
} }
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
void ConnectRequest::dump_to(std::string &out) const { dump_field(out, "password", this->password); } void AuthenticationRequest::dump_to(std::string &out) const { dump_field(out, "password", this->password); }
void ConnectResponse::dump_to(std::string &out) const { dump_field(out, "invalid_password", this->invalid_password); } void AuthenticationResponse::dump_to(std::string &out) const {
MessageDumpHelper helper(out, "AuthenticationResponse");
dump_field(out, "invalid_password", this->invalid_password);
}
#endif #endif
void DisconnectRequest::dump_to(std::string &out) const { out.append("DisconnectRequest {}"); } void DisconnectRequest::dump_to(std::string &out) const { out.append("DisconnectRequest {}"); }
void DisconnectResponse::dump_to(std::string &out) const { out.append("DisconnectResponse {}"); } void DisconnectResponse::dump_to(std::string &out) const { out.append("DisconnectResponse {}"); }

View File

@@ -25,13 +25,13 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
break; break;
} }
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
case ConnectRequest::MESSAGE_TYPE: { case AuthenticationRequest::MESSAGE_TYPE: {
ConnectRequest msg; AuthenticationRequest msg;
msg.decode(msg_data, msg_size); msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP #ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_connect_request: %s", msg.dump().c_str()); ESP_LOGVV(TAG, "on_authentication_request: %s", msg.dump().c_str());
#endif #endif
this->on_connect_request(msg); this->on_authentication_request(msg);
break; break;
} }
#endif #endif
@@ -622,8 +622,8 @@ void APIServerConnection::on_hello_request(const HelloRequest &msg) {
} }
} }
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
void APIServerConnection::on_connect_request(const ConnectRequest &msg) { void APIServerConnection::on_authentication_request(const AuthenticationRequest &msg) {
if (!this->send_connect_response(msg)) { if (!this->send_authenticate_response(msg)) {
this->on_fatal_error(); this->on_fatal_error();
} }
} }

View File

@@ -27,7 +27,7 @@ class APIServerConnectionBase : public ProtoService {
virtual void on_hello_request(const HelloRequest &value){}; virtual void on_hello_request(const HelloRequest &value){};
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
virtual void on_connect_request(const ConnectRequest &value){}; virtual void on_authentication_request(const AuthenticationRequest &value){};
#endif #endif
virtual void on_disconnect_request(const DisconnectRequest &value){}; virtual void on_disconnect_request(const DisconnectRequest &value){};
@@ -222,7 +222,7 @@ class APIServerConnection : public APIServerConnectionBase {
public: public:
virtual bool send_hello_response(const HelloRequest &msg) = 0; virtual bool send_hello_response(const HelloRequest &msg) = 0;
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
virtual bool send_connect_response(const ConnectRequest &msg) = 0; virtual bool send_authenticate_response(const AuthenticationRequest &msg) = 0;
#endif #endif
virtual bool send_disconnect_response(const DisconnectRequest &msg) = 0; virtual bool send_disconnect_response(const DisconnectRequest &msg) = 0;
virtual bool send_ping_response(const PingRequest &msg) = 0; virtual bool send_ping_response(const PingRequest &msg) = 0;
@@ -351,7 +351,7 @@ class APIServerConnection : public APIServerConnectionBase {
protected: protected:
void on_hello_request(const HelloRequest &msg) override; void on_hello_request(const HelloRequest &msg) override;
#ifdef USE_API_PASSWORD #ifdef USE_API_PASSWORD
void on_connect_request(const ConnectRequest &msg) override; void on_authentication_request(const AuthenticationRequest &msg) override;
#endif #endif
void on_disconnect_request(const DisconnectRequest &msg) override; void on_disconnect_request(const DisconnectRequest &msg) override;
void on_ping_request(const PingRequest &msg) override; void on_ping_request(const PingRequest &msg) override;

View File

@@ -1,12 +0,0 @@
#include "string_ref.h"
namespace esphome {
#ifdef USE_JSON
// NOLINTNEXTLINE(readability-identifier-naming)
void convertToJson(const StringRef &src, JsonVariant dst) { dst.set(src.c_str()); }
#endif // USE_JSON
} // namespace esphome

View File

@@ -130,7 +130,7 @@ inline std::string operator+(const StringRef &lhs, const char *rhs) {
#ifdef USE_JSON #ifdef USE_JSON
// NOLINTNEXTLINE(readability-identifier-naming) // NOLINTNEXTLINE(readability-identifier-naming)
void convertToJson(const StringRef &src, JsonVariant dst); inline void convertToJson(const StringRef &src, JsonVariant dst) { dst.set(src.c_str()); }
#endif // USE_JSON #endif // USE_JSON
} // namespace esphome } // namespace esphome

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "esphome" name = "esphome"
license = {text = "MIT"} license = "MIT"
description = "ESPHome is a system to configure your microcontrollers by simple yet powerful configuration files and control them remotely through Home Automation systems." description = "ESPHome is a system to configure your microcontrollers by simple yet powerful configuration files and control them remotely through Home Automation systems."
readme = "README.md" readme = "README.md"
authors = [ authors = [
@@ -15,7 +15,6 @@ classifiers = [
"Environment :: Console", "Environment :: Console",
"Intended Audience :: Developers", "Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop", "Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: MIT License",
"Programming Language :: C++", "Programming Language :: C++",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Topic :: Home Automation", "Topic :: Home Automation",

View File

@@ -12,7 +12,7 @@ platformio==6.1.18 # When updating platformio, also update /docker/Dockerfile
esptool==5.0.2 esptool==5.0.2
click==8.1.7 click==8.1.7
esphome-dashboard==20250904.0 esphome-dashboard==20250904.0
aioesphomeapi==40.2.1 aioesphomeapi==41.1.0
zeroconf==0.147.2 zeroconf==0.147.2
puremagic==1.30 puremagic==1.30
ruamel.yaml==0.18.15 # dashboard_import ruamel.yaml==0.18.15 # dashboard_import

View File

@@ -1226,6 +1226,18 @@ def test_has_mqtt_logging_no_log_topic() -> None:
setup_core(config={}) setup_core(config={})
assert has_mqtt_logging() is False assert has_mqtt_logging() is False
# Setup MQTT config with CONF_LOG_TOPIC but no CONF_LEVEL (regression test for #10771)
# This simulates the default configuration created by validate_config in the MQTT component
setup_core(
config={
CONF_MQTT: {
CONF_BROKER: "mqtt.local",
CONF_LOG_TOPIC: {CONF_TOPIC: "esphome/debug"},
}
}
)
assert has_mqtt_logging() is True
def test_has_mqtt() -> None: def test_has_mqtt() -> None:
"""Test has_mqtt function.""" """Test has_mqtt function."""