mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 00:48:19 +01:00
Expose webserver_port to the native API (#2640)
This commit is contained in:
parent
2b04152482
commit
d8b3af3815
6 changed files with 20 additions and 0 deletions
|
@ -182,6 +182,8 @@ message DeviceInfoResponse {
|
||||||
// The esphome project details if set
|
// The esphome project details if set
|
||||||
string project_name = 8;
|
string project_name = 8;
|
||||||
string project_version = 9;
|
string project_version = 9;
|
||||||
|
|
||||||
|
uint32 webserver_port = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListEntitiesRequest {
|
message ListEntitiesRequest {
|
||||||
|
|
|
@ -759,6 +759,9 @@ DeviceInfoResponse APIConnection::device_info(const DeviceInfoRequest &msg) {
|
||||||
#ifdef ESPHOME_PROJECT_NAME
|
#ifdef ESPHOME_PROJECT_NAME
|
||||||
resp.project_name = ESPHOME_PROJECT_NAME;
|
resp.project_name = ESPHOME_PROJECT_NAME;
|
||||||
resp.project_version = ESPHOME_PROJECT_VERSION;
|
resp.project_version = ESPHOME_PROJECT_VERSION;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
resp.webserver_port = WEBSERVER_PORT;
|
||||||
#endif
|
#endif
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,6 +396,10 @@ bool DeviceInfoResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||||
this->has_deep_sleep = value.as_bool();
|
this->has_deep_sleep = value.as_bool();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case 10: {
|
||||||
|
this->webserver_port = value.as_uint32();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -444,6 +448,7 @@ void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const {
|
||||||
buffer.encode_bool(7, this->has_deep_sleep);
|
buffer.encode_bool(7, this->has_deep_sleep);
|
||||||
buffer.encode_string(8, this->project_name);
|
buffer.encode_string(8, this->project_name);
|
||||||
buffer.encode_string(9, this->project_version);
|
buffer.encode_string(9, this->project_version);
|
||||||
|
buffer.encode_uint32(10, this->webserver_port);
|
||||||
}
|
}
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
void DeviceInfoResponse::dump_to(std::string &out) const {
|
void DeviceInfoResponse::dump_to(std::string &out) const {
|
||||||
|
@ -484,6 +489,11 @@ void DeviceInfoResponse::dump_to(std::string &out) const {
|
||||||
out.append(" project_version: ");
|
out.append(" project_version: ");
|
||||||
out.append("'").append(this->project_version).append("'");
|
out.append("'").append(this->project_version).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
|
out.append(" webserver_port: ");
|
||||||
|
sprintf(buffer, "%u", this->webserver_port);
|
||||||
|
out.append(buffer);
|
||||||
|
out.append("\n");
|
||||||
out.append("}");
|
out.append("}");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -224,6 +224,7 @@ class DeviceInfoResponse : public ProtoMessage {
|
||||||
bool has_deep_sleep{false};
|
bool has_deep_sleep{false};
|
||||||
std::string project_name{};
|
std::string project_name{};
|
||||||
std::string project_version{};
|
std::string project_version{};
|
||||||
|
uint32_t webserver_port{0};
|
||||||
void encode(ProtoWriteBuffer buffer) const override;
|
void encode(ProtoWriteBuffer buffer) 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;
|
||||||
|
|
|
@ -54,6 +54,7 @@ async def to_code(config):
|
||||||
|
|
||||||
cg.add(paren.set_port(config[CONF_PORT]))
|
cg.add(paren.set_port(config[CONF_PORT]))
|
||||||
cg.add_define("WEBSERVER_PORT", config[CONF_PORT])
|
cg.add_define("WEBSERVER_PORT", config[CONF_PORT])
|
||||||
|
cg.add_define("USE_WEBSERVER")
|
||||||
cg.add(var.set_css_url(config[CONF_CSS_URL]))
|
cg.add(var.set_css_url(config[CONF_CSS_URL]))
|
||||||
cg.add(var.set_js_url(config[CONF_JS_URL]))
|
cg.add(var.set_js_url(config[CONF_JS_URL]))
|
||||||
if CONF_AUTH in config:
|
if CONF_AUTH in config:
|
||||||
|
|
|
@ -36,8 +36,11 @@
|
||||||
#define USE_SWITCH
|
#define USE_SWITCH
|
||||||
#define USE_TEXT_SENSOR
|
#define USE_TEXT_SENSOR
|
||||||
#define USE_TIME
|
#define USE_TIME
|
||||||
|
#define USE_WEBSERVER
|
||||||
#define USE_WIFI
|
#define USE_WIFI
|
||||||
|
|
||||||
|
#define WEBSERVER_PORT 80 // NOLINT
|
||||||
|
|
||||||
// Arduino-specific feature flags
|
// Arduino-specific feature flags
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
#define USE_CAPTIVE_PORTAL
|
#define USE_CAPTIVE_PORTAL
|
||||||
|
|
Loading…
Reference in a new issue