1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-18 15:55:46 +00:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Clyde Stubbs
11d0d4d128 [lvgl] Apply scale to spinbox value (#11946) 2025-11-18 17:27:50 +13:00
Clyde Stubbs
a4242dee64 [build] Don't clear pio cache unless requested (#11966) 2025-11-18 15:11:49 +11:00
J. Nick Koston
0d6c9623ce [dashboard_import] Store package import URL in .rodata instead of RAM (#11951) 2025-11-17 20:02:16 -06:00
strange_v
0923bcd2ca [mipi_rgb] Fix GUITION-4848S040 colors (#11709) 2025-11-18 01:32:17 +00:00
J. Nick Koston
fdc7ae7760 [wifi] Skip redundant setter calls for default values (#11943) 2025-11-17 17:20:32 -06:00
J. Nick Koston
1a73f49cd2 [number] Modernize to C++17 nested namespaces (#11945) 2025-11-17 17:20:18 -06:00
24 changed files with 60 additions and 84 deletions

View File

@@ -13,16 +13,14 @@ static const char *const TAG = "captive_portal";
void CaptivePortal::handle_config(AsyncWebServerRequest *request) {
AsyncResponseStream *stream = request->beginResponseStream(ESPHOME_F("application/json"));
stream->addHeader(ESPHOME_F("cache-control"), ESPHOME_F("public, max-age=0, must-revalidate"));
char mac_s[18];
const char *mac_str = get_mac_address_pretty_into_buffer(mac_s);
#ifdef USE_ESP8266
stream->print(ESPHOME_F("{\"mac\":\""));
stream->print(mac_str);
stream->print(get_mac_address_pretty().c_str());
stream->print(ESPHOME_F("\",\"name\":\""));
stream->print(App.get_name().c_str());
stream->print(ESPHOME_F("\",\"aps\":[{}"));
#else
stream->printf(R"({"mac":"%s","name":"%s","aps":[{})", mac_str, App.get_name().c_str());
stream->printf(R"({"mac":"%s","name":"%s","aps":[{})", get_mac_address_pretty().c_str(), App.get_name().c_str());
#endif
for (auto &scan : wifi::global_wifi_component->get_scan_result()) {

View File

@@ -3,10 +3,10 @@
namespace esphome {
namespace dashboard_import {
static std::string g_package_import_url; // NOLINT
static const char *g_package_import_url = ""; // NOLINT
const std::string &get_package_import_url() { return g_package_import_url; }
void set_package_import_url(std::string url) { g_package_import_url = std::move(url); }
const char *get_package_import_url() { return g_package_import_url; }
void set_package_import_url(const char *url) { g_package_import_url = url; }
} // namespace dashboard_import
} // namespace esphome

View File

@@ -1,12 +1,10 @@
#pragma once
#include <string>
namespace esphome {
namespace dashboard_import {
const std::string &get_package_import_url();
void set_package_import_url(std::string url);
const char *get_package_import_url();
void set_package_import_url(const char *url);
} // namespace dashboard_import
} // namespace esphome

View File

@@ -1,6 +1,7 @@
from esphome import automation
import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_RANGE_FROM, CONF_RANGE_TO, CONF_STEP, CONF_VALUE
from esphome.cpp_generator import MockObj
from ..automation import action_to_code
from ..defines import (
@@ -114,7 +115,9 @@ class SpinboxType(WidgetType):
w.obj, digits, digits - config[CONF_DECIMAL_PLACES]
)
if (value := config.get(CONF_VALUE)) is not None:
lv.spinbox_set_value(w.obj, await lv_float.process(value))
lv.spinbox_set_value(
w.obj, MockObj(await lv_float.process(value)) * w.get_scale()
)
def get_scale(self, config):
return 10 ** config[CONF_DECIMAL_PLACES]

View File

@@ -135,8 +135,7 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
#ifdef USE_DASHBOARD_IMPORT
MDNS_STATIC_CONST_CHAR(TXT_PACKAGE_IMPORT_URL, "package_import_url");
txt_records.push_back(
{MDNS_STR(TXT_PACKAGE_IMPORT_URL), MDNS_STR(dashboard_import::get_package_import_url().c_str())});
txt_records.push_back({MDNS_STR(TXT_PACKAGE_IMPORT_URL), MDNS_STR(dashboard_import::get_package_import_url())});
#endif
}
#endif // USE_API

View File

@@ -350,6 +350,7 @@ void MipiRgb::dump_config() {
"\n Width: %u"
"\n Height: %u"
"\n Rotation: %d degrees"
"\n PCLK Inverted: %s"
"\n HSync Pulse Width: %u"
"\n HSync Back Porch: %u"
"\n HSync Front Porch: %u"
@@ -357,18 +358,18 @@ void MipiRgb::dump_config() {
"\n VSync Back Porch: %u"
"\n VSync Front Porch: %u"
"\n Invert Colors: %s"
"\n Pixel Clock: %dMHz"
"\n Pixel Clock: %uMHz"
"\n Reset Pin: %s"
"\n DE Pin: %s"
"\n PCLK Pin: %s"
"\n HSYNC Pin: %s"
"\n VSYNC Pin: %s",
this->model_, this->width_, this->height_, this->rotation_, this->hsync_pulse_width_,
this->hsync_back_porch_, this->hsync_front_porch_, this->vsync_pulse_width_, this->vsync_back_porch_,
this->vsync_front_porch_, YESNO(this->invert_colors_), this->pclk_frequency_ / 1000000,
get_pin_name(this->reset_pin_).c_str(), get_pin_name(this->de_pin_).c_str(),
get_pin_name(this->pclk_pin_).c_str(), get_pin_name(this->hsync_pin_).c_str(),
get_pin_name(this->vsync_pin_).c_str());
this->model_, this->width_, this->height_, this->rotation_, YESNO(this->pclk_inverted_),
this->hsync_pulse_width_, this->hsync_back_porch_, this->hsync_front_porch_, this->vsync_pulse_width_,
this->vsync_back_porch_, this->vsync_front_porch_, YESNO(this->invert_colors_),
(unsigned) (this->pclk_frequency_ / 1000000), get_pin_name(this->reset_pin_).c_str(),
get_pin_name(this->de_pin_).c_str(), get_pin_name(this->pclk_pin_).c_str(),
get_pin_name(this->hsync_pin_).c_str(), get_pin_name(this->vsync_pin_).c_str());
if (this->madctl_ & MADCTL_BGR) {
this->dump_pins_(8, 13, "Blue", 0);

View File

@@ -11,6 +11,7 @@ st7701s.extend(
vsync_pin=17,
pclk_pin=21,
pclk_frequency="12MHz",
pclk_inverted=False,
pixel_mode="18bit",
mirror_x=True,
mirror_y=True,

View File

@@ -1,8 +1,7 @@
#include "automation.h"
#include "esphome/core/log.h"
namespace esphome {
namespace number {
namespace esphome::number {
static const char *const TAG = "number.automation";
@@ -52,5 +51,4 @@ void ValueRangeTrigger::on_state_(float state) {
this->rtc_.save(&in_range);
}
} // namespace number
} // namespace esphome
} // namespace esphome::number

View File

@@ -4,8 +4,7 @@
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
namespace esphome {
namespace number {
namespace esphome::number {
class NumberStateTrigger : public Trigger<float> {
public:
@@ -91,5 +90,4 @@ template<typename... Ts> class NumberInRangeCondition : public Condition<Ts...>
float max_{NAN};
};
} // namespace number
} // namespace esphome
} // namespace esphome::number

View File

@@ -3,8 +3,7 @@
#include "esphome/core/controller_registry.h"
#include "esphome/core/log.h"
namespace esphome {
namespace number {
namespace esphome::number {
static const char *const TAG = "number";
@@ -43,5 +42,4 @@ void Number::add_on_state_callback(std::function<void(float)> &&callback) {
this->state_callback_.add(std::move(callback));
}
} // namespace number
} // namespace esphome
} // namespace esphome::number

View File

@@ -6,8 +6,7 @@
#include "number_call.h"
#include "number_traits.h"
namespace esphome {
namespace number {
namespace esphome::number {
class Number;
void log_number(const char *tag, const char *prefix, const char *type, Number *obj);
@@ -53,5 +52,4 @@ class Number : public EntityBase {
CallbackManager<void(float)> state_callback_;
};
} // namespace number
} // namespace esphome
} // namespace esphome::number

View File

@@ -2,8 +2,7 @@
#include "number.h"
#include "esphome/core/log.h"
namespace esphome {
namespace number {
namespace esphome::number {
static const char *const TAG = "number";
@@ -125,5 +124,4 @@ void NumberCall::perform() {
this->parent_->control(target_value);
}
} // namespace number
} // namespace esphome
} // namespace esphome::number

View File

@@ -4,8 +4,7 @@
#include "esphome/core/log.h"
#include "number_traits.h"
namespace esphome {
namespace number {
namespace esphome::number {
class Number;
@@ -44,5 +43,4 @@ class NumberCall {
bool cycle_;
};
} // namespace number
} // namespace esphome
} // namespace esphome::number

View File

@@ -1,10 +1,8 @@
#include "esphome/core/log.h"
#include "number_traits.h"
namespace esphome {
namespace number {
namespace esphome::number {
static const char *const TAG = "number";
} // namespace number
} // namespace esphome
} // namespace esphome::number

View File

@@ -3,8 +3,7 @@
#include "esphome/core/entity_base.h"
#include "esphome/core/helpers.h"
namespace esphome {
namespace number {
namespace esphome::number {
enum NumberMode : uint8_t {
NUMBER_MODE_AUTO = 0,
@@ -35,5 +34,4 @@ class NumberTraits : public EntityBase_DeviceClass, public EntityBase_UnitOfMeas
NumberMode mode_{NUMBER_MODE_AUTO};
};
} // namespace number
} // namespace esphome
} // namespace esphome::number

View File

@@ -359,8 +359,8 @@ void WebServer::handle_pna_cors_request(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginResponse(200, "");
response->addHeader(HEADER_CORS_ALLOW_PNA, "true");
response->addHeader(HEADER_PNA_NAME, App.get_name().c_str());
char mac_s[18];
response->addHeader(HEADER_PNA_ID, get_mac_address_pretty_into_buffer(mac_s));
std::string mac = get_mac_address_pretty();
response->addHeader(HEADER_PNA_ID, mac.c_str());
request->send(response);
}
#endif

View File

@@ -479,11 +479,14 @@ async def to_code(config):
cg.add(var.set_min_auth_mode(config[CONF_MIN_AUTH_MODE]))
if config[CONF_FAST_CONNECT]:
cg.add_define("USE_WIFI_FAST_CONNECT")
cg.add(var.set_passive_scan(config[CONF_PASSIVE_SCAN]))
# passive_scan defaults to false in C++ - only set if true
if config[CONF_PASSIVE_SCAN]:
cg.add(var.set_passive_scan(True))
if CONF_OUTPUT_POWER in config:
cg.add(var.set_output_power(config[CONF_OUTPUT_POWER]))
cg.add(var.set_enable_on_boot(config[CONF_ENABLE_ON_BOOT]))
# enable_on_boot defaults to true in C++ - only set if false
if not config[CONF_ENABLE_ON_BOOT]:
cg.add(var.set_enable_on_boot(False))
if CORE.is_esp8266:
cg.add_library("ESP8266WiFi", None)

View File

@@ -334,11 +334,10 @@ void WiFiComponent::setup() {
}
void WiFiComponent::start() {
char mac_s[18];
ESP_LOGCONFIG(TAG,
"Starting\n"
" Local MAC: %s",
get_mac_address_pretty_into_buffer(mac_s));
get_mac_address_pretty().c_str());
this->last_connected_ = millis();
uint32_t hash = this->has_sta() ? fnv1_hash(App.get_compilation_time()) : 88491487UL;
@@ -801,8 +800,7 @@ void WiFiComponent::print_connect_params_() {
char bssid_s[18];
format_mac_addr_upper(bssid.data(), bssid_s);
char mac_s[18];
ESP_LOGCONFIG(TAG, " Local MAC: %s", get_mac_address_pretty_into_buffer(mac_s));
ESP_LOGCONFIG(TAG, " Local MAC: %s", get_mac_address_pretty().c_str());
if (this->is_disabled()) {
ESP_LOGCONFIG(TAG, " Disabled");
return;

View File

@@ -526,7 +526,7 @@ class WiFiComponent : public Component {
bool btm_{false};
bool rrm_{false};
#endif
bool enable_on_boot_;
bool enable_on_boot_{true};
bool got_ipv4_address_{false};
bool keep_scan_results_{false};

View File

@@ -126,10 +126,7 @@ class BSSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor {
class MacAddressWifiInfo : public Component, public text_sensor::TextSensor {
public:
void setup() override {
char mac_s[18];
this->publish_state(get_mac_address_pretty_into_buffer(mac_s));
}
void setup() override { this->publish_state(get_mac_address_pretty()); }
void dump_config() override;
};

View File

@@ -638,8 +638,9 @@ std::string get_mac_address() {
}
std::string get_mac_address_pretty() {
char buf[18];
return std::string(get_mac_address_pretty_into_buffer(buf));
uint8_t mac[6];
get_mac_address_raw(mac);
return format_mac_address_pretty(mac);
}
void get_mac_address_into_buffer(std::span<char, 13> buf) {
@@ -648,13 +649,6 @@ void get_mac_address_into_buffer(std::span<char, 13> buf) {
format_mac_addr_lower_no_sep(mac, buf.data());
}
const char *get_mac_address_pretty_into_buffer(std::span<char, 18> buf) {
uint8_t mac[6];
get_mac_address_raw(mac);
format_mac_addr_upper(mac, buf.data());
return buf.data();
}
#ifndef USE_ESP32
bool has_custom_mac_address() { return false; }
#endif

View File

@@ -1052,11 +1052,6 @@ std::string get_mac_address_pretty();
/// Assumes buffer length is 13 (12 digits for hexadecimal representation followed by null terminator).
void get_mac_address_into_buffer(std::span<char, 13> buf);
/// Get the device MAC address into the given buffer, in colon-separated uppercase hex notation.
/// Buffer must be exactly 18 bytes (17 for "XX:XX:XX:XX:XX:XX" + null terminator).
/// Returns pointer to the buffer for convenience.
const char *get_mac_address_pretty_into_buffer(std::span<char, 18> buf);
#ifdef USE_ESP32
/// Set the MAC address to use from the provided byte array (6 bytes).
void set_mac_address(uint8_t *mac);

View File

@@ -121,7 +121,7 @@ def update_storage_json() -> None:
)
else:
_LOGGER.info("Core config or version changed, cleaning build files...")
clean_build()
clean_build(clear_pio_cache=False)
elif storage_should_update_cmake_cache(old, new):
_LOGGER.info("Integrations changed, cleaning cmake cache...")
clean_cmake_cache()
@@ -301,7 +301,7 @@ def clean_cmake_cache():
pioenvs_cmake_path.unlink()
def clean_build():
def clean_build(clear_pio_cache: bool = True):
import shutil
# Allow skipping cache cleaning for integration tests
@@ -322,6 +322,9 @@ def clean_build():
_LOGGER.info("Deleting %s", dependencies_lock)
dependencies_lock.unlink()
if not clear_pio_cache:
return
# Clean PlatformIO cache to resolve CMake compiler detection issues
# This helps when toolchain paths change or get corrupted
try:

View File

@@ -703,7 +703,9 @@ lvgl:
on_value:
- lvgl.spinbox.update:
id: spinbox_id
value: !lambda return x;
value: !lambda |-
static float yyy = 83.0;
return yyy + .8;
- button:
styles: spin_button
id: spin_up