esphome 2024.11.3__py3-none-any.whl → 2024.12.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/components/adc/adc_sensor.h +7 -8
- esphome/components/adc/adc_sensor_common.cpp +24 -0
- esphome/components/adc/{adc_sensor.cpp → adc_sensor_esp32.cpp} +10 -179
- esphome/components/adc/adc_sensor_esp8266.cpp +58 -0
- esphome/components/adc/adc_sensor_libretiny.cpp +48 -0
- esphome/components/adc/adc_sensor_rp2040.cpp +93 -0
- esphome/components/alarm_control_panel/alarm_control_panel_call.cpp +3 -4
- esphome/components/animation/__init__.py +1 -2
- esphome/components/apds9306/apds9306.cpp +2 -1
- esphome/components/audio/audio.h +1 -1
- esphome/components/bk72xx/__init__.py +1 -1
- esphome/components/cse7766/cse7766.cpp +1 -1
- esphome/components/deep_sleep/deep_sleep_esp32.cpp +2 -2
- esphome/components/dht/dht.cpp +2 -1
- esphome/components/display/display.cpp +10 -6
- esphome/components/display/display.h +14 -0
- esphome/components/display_menu_base/__init__.py +0 -2
- esphome/components/display_menu_base/display_menu_base.cpp +1 -1
- esphome/components/dsmr/dsmr.cpp +1 -1
- esphome/components/esp32/__init__.py +94 -12
- esphome/components/esp32/boards.py +222 -14
- esphome/components/esp32_ble/__init__.py +22 -2
- esphome/components/esp32_ble/ble.cpp +39 -12
- esphome/components/esp32_ble/ble.h +2 -0
- esphome/components/esp32_ble/ble_advertising.cpp +1 -1
- esphome/components/esp32_ble/ble_uuid.cpp +9 -10
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +4 -1
- esphome/components/esp32_camera_web_server/camera_web_server.h +1 -1
- esphome/components/esp32_rmt_led_strip/light.py +3 -3
- esphome/components/esp8266/__init__.py +5 -7
- esphome/components/ezo/ezo.cpp +14 -26
- esphome/components/font/__init__.py +10 -25
- esphome/components/font/font.cpp +5 -3
- esphome/components/graphical_display_menu/__init__.py +2 -0
- esphome/components/haier/hon_climate.cpp +79 -80
- esphome/components/hbridge/switch/__init__.py +44 -0
- esphome/components/hbridge/switch/hbridge_switch.cpp +95 -0
- esphome/components/hbridge/switch/hbridge_switch.h +50 -0
- esphome/components/hitachi_ac344/hitachi_ac344.cpp +4 -2
- esphome/components/hitachi_ac424/hitachi_ac424.cpp +4 -2
- esphome/components/homeassistant/number/homeassistant_number.cpp +3 -0
- esphome/components/hx711/hx711.cpp +1 -1
- esphome/components/hx711/hx711.h +1 -1
- esphome/components/i2c/i2c_bus_esp_idf.cpp +2 -2
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +61 -59
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +8 -17
- esphome/components/ili9xxx/display.py +1 -2
- esphome/components/ili9xxx/ili9xxx_display.cpp +3 -2
- esphome/components/image/__init__.py +1 -2
- esphome/components/logger/logger.cpp +1 -1
- esphome/components/ltr501/ltr501.cpp +1 -1
- esphome/components/lvgl/defines.py +8 -1
- esphome/components/lvgl/lv_validation.py +8 -3
- esphome/components/lvgl/lvgl_esphome.cpp +1 -1
- esphome/components/lvgl/lvgl_esphome.h +16 -0
- esphome/components/lvgl/widgets/animimg.py +12 -17
- esphome/components/lvgl/widgets/img.py +1 -3
- esphome/components/matrix_keypad/__init__.py +15 -3
- esphome/components/matrix_keypad/matrix_keypad.cpp +4 -0
- esphome/components/matrix_keypad/matrix_keypad.h +5 -0
- esphome/components/max31865/max31865.cpp +4 -2
- esphome/components/modbus_controller/modbus_controller.cpp +24 -24
- esphome/components/modbus_controller/modbus_controller.h +22 -22
- esphome/components/modbus_controller/number/modbus_number.cpp +8 -8
- esphome/components/modbus_controller/number/modbus_number.h +4 -4
- esphome/components/modbus_controller/output/modbus_output.cpp +7 -6
- esphome/components/modbus_controller/output/modbus_output.h +5 -5
- esphome/components/modbus_controller/select/modbus_select.cpp +4 -3
- esphome/components/modbus_controller/select/modbus_select.h +4 -4
- esphome/components/modbus_controller/switch/modbus_switch.cpp +5 -5
- esphome/components/modbus_controller/switch/modbus_switch.h +2 -2
- esphome/components/mqtt/__init__.py +4 -0
- esphome/components/mqtt/mqtt_alarm_control_panel.cpp +2 -5
- esphome/components/mqtt/mqtt_backend_esp32.cpp +3 -3
- esphome/components/mqtt/mqtt_client.cpp +4 -0
- esphome/components/mqtt/mqtt_client.h +6 -0
- esphome/components/mqtt/mqtt_climate.cpp +13 -3
- esphome/components/mqtt/mqtt_sensor.cpp +2 -0
- esphome/components/network/ip_address.h +1 -1
- esphome/components/nextion/__init__.py +2 -0
- esphome/components/nextion/automation.h +76 -0
- esphome/components/nextion/base_component.py +1 -0
- esphome/components/nextion/binary_sensor/__init__.py +43 -2
- esphome/components/nextion/display.py +15 -0
- esphome/components/nextion/nextion.cpp +8 -5
- esphome/components/nextion/nextion.h +7 -0
- esphome/components/nextion/nextion_upload_idf.cpp +2 -2
- esphome/components/nextion/sensor/__init__.py +38 -5
- esphome/components/nextion/switch/__init__.py +38 -2
- esphome/components/nextion/text_sensor/__init__.py +37 -2
- esphome/components/nfc/ndef_record.cpp +3 -3
- esphome/components/online_image/__init__.py +1 -0
- esphome/components/opentherm/opentherm.cpp +3 -3
- esphome/components/opentherm/opentherm.h +1 -1
- esphome/components/ota/automation.h +1 -1
- esphome/components/output/float_output.cpp +1 -1
- esphome/components/pca6416a/pca6416a.cpp +5 -3
- esphome/components/pca9554/pca9554.cpp +4 -4
- esphome/components/pipsolar/pipsolar.cpp +2 -2
- esphome/components/pipsolar/switch/pipsolar_switch.cpp +2 -2
- esphome/components/pn532/pn532_mifare_ultralight.cpp +2 -2
- esphome/components/pn7150/pn7150_mifare_ultralight.cpp +2 -2
- esphome/components/pn7160/pn7160_mifare_ultralight.cpp +2 -2
- esphome/components/qmc5883l/qmc5883l.cpp +45 -19
- esphome/components/qmc5883l/qmc5883l.h +1 -1
- esphome/components/qspi_dbi/qspi_dbi.cpp +2 -1
- esphome/components/remote_base/raw_protocol.cpp +1 -1
- esphome/components/remote_receiver/__init__.py +5 -6
- esphome/components/rotary_encoder/rotary_encoder.cpp +3 -1
- esphome/components/rp2040/__init__.py +1 -1
- esphome/components/rtl87xx/__init__.py +1 -1
- esphome/components/safe_mode/automation.h +1 -1
- esphome/components/seeed_mr60bha2/__init__.py +41 -0
- esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp +173 -0
- esphome/components/seeed_mr60bha2/seeed_mr60bha2.h +61 -0
- esphome/components/seeed_mr60bha2/sensor.py +57 -0
- esphome/components/seeed_mr60fda2/__init__.py +41 -0
- esphome/components/seeed_mr60fda2/binary_sensor.py +33 -0
- esphome/components/seeed_mr60fda2/button/__init__.py +45 -0
- esphome/components/seeed_mr60fda2/button/get_radar_parameters_button.cpp +9 -0
- esphome/components/seeed_mr60fda2/button/get_radar_parameters_button.h +18 -0
- esphome/components/seeed_mr60fda2/button/reset_radar_button.cpp +9 -0
- esphome/components/seeed_mr60fda2/button/reset_radar_button.h +18 -0
- esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +368 -0
- esphome/components/seeed_mr60fda2/seeed_mr60fda2.h +101 -0
- esphome/components/seeed_mr60fda2/select/__init__.py +59 -0
- esphome/components/seeed_mr60fda2/select/height_threshold_select.cpp +15 -0
- esphome/components/seeed_mr60fda2/select/height_threshold_select.h +18 -0
- esphome/components/seeed_mr60fda2/select/install_height_select.cpp +15 -0
- esphome/components/seeed_mr60fda2/select/install_height_select.h +18 -0
- esphome/components/seeed_mr60fda2/select/sensitivity_select.cpp +15 -0
- esphome/components/seeed_mr60fda2/select/sensitivity_select.h +18 -0
- esphome/components/sen5x/sensor.py +5 -6
- esphome/components/sgp30/sensor.py +8 -9
- esphome/components/sgp30/sgp30.cpp +2 -6
- esphome/components/shelly_dimmer/shelly_dimmer.cpp +1 -1
- esphome/components/sim800l/sim800l.cpp +1 -1
- esphome/components/sntp/sntp_component.cpp +14 -20
- esphome/components/sntp/sntp_component.h +6 -9
- esphome/components/sntp/time.py +4 -7
- esphome/components/sprinkler/sprinkler.cpp +2 -2
- esphome/components/st7735/st7735.cpp +1 -1
- esphome/components/st7789v/st7789v.cpp +1 -1
- esphome/components/stepper/stepper.h +0 -1
- esphome/components/sun_gtil2/sun_gtil2.cpp +1 -1
- esphome/components/switch/binary_sensor/__init__.py +31 -0
- esphome/components/switch/binary_sensor/switch_binary_sensor.cpp +17 -0
- esphome/components/switch/binary_sensor/switch_binary_sensor.h +22 -0
- esphome/components/sx1509/sx1509_gpio_pin.cpp +2 -1
- esphome/components/sx1509/sx1509_gpio_pin.h +5 -5
- esphome/components/uart/uart.h +1 -1
- esphome/components/udp/udp_component.cpp +32 -16
- esphome/components/ufire_ec/sensor.py +4 -4
- esphome/components/uln2003/uln2003.cpp +4 -1
- esphome/components/waveshare_epaper/display.py +8 -0
- esphome/components/waveshare_epaper/waveshare_epaper.cpp +191 -0
- esphome/components/waveshare_epaper/waveshare_epaper.h +56 -0
- esphome/components/wiegand/__init__.py +3 -4
- esphome/components/wifi/__init__.py +42 -0
- esphome/components/wifi/wifi_component.cpp +2 -2
- esphome/components/wifi/wifi_component.h +82 -1
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +1 -1
- esphome/components/wifi/wifi_component_esp8266.cpp +1 -1
- esphome/components/wifi/wifi_component_esp_idf.cpp +1 -1
- esphome/components/wifi/wifi_component_libretiny.cpp +1 -1
- esphome/components/wifi/wifi_component_pico_w.cpp +1 -1
- esphome/components/wireguard/wireguard.cpp +2 -2
- esphome/components/xiaomi_ble/xiaomi_ble.cpp +1 -1
- esphome/config_validation.py +15 -11
- esphome/const.py +11 -1
- esphome/core/component.cpp +1 -1
- esphome/core/config.py +1 -2
- esphome/core/defines.h +3 -1
- esphome/core/helpers.cpp +8 -2
- esphome/core/helpers.h +2 -1
- esphome/core/optional.h +2 -2
- esphome/dashboard/web_server.py +6 -0
- {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/METADATA +4 -4
- {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/RECORD +183 -153
- {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/LICENSE +0 -0
- {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/WHEEL +0 -0
- {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/top_level.txt +0 -0
@@ -2,8 +2,10 @@ from esphome import automation
|
|
2
2
|
import esphome.codegen as cg
|
3
3
|
from esphome.components.esp32 import add_idf_sdkconfig_option, const, get_esp32_variant
|
4
4
|
import esphome.config_validation as cv
|
5
|
-
from esphome.const import CONF_ENABLE_ON_BOOT, CONF_ID
|
5
|
+
from esphome.const import CONF_ENABLE_ON_BOOT, CONF_ESPHOME, CONF_ID, CONF_NAME
|
6
6
|
from esphome.core import CORE
|
7
|
+
from esphome.core.config import CONF_NAME_ADD_MAC_SUFFIX
|
8
|
+
import esphome.final_validate as fv
|
7
9
|
|
8
10
|
DEPENDENCIES = ["esp32"]
|
9
11
|
CODEOWNERS = ["@jesserockz", "@Rapsssito"]
|
@@ -50,6 +52,7 @@ TX_POWER_LEVELS = {
|
|
50
52
|
CONFIG_SCHEMA = cv.Schema(
|
51
53
|
{
|
52
54
|
cv.GenerateID(): cv.declare_id(ESP32BLE),
|
55
|
+
cv.Optional(CONF_NAME): cv.All(cv.string, cv.Length(max=20)),
|
53
56
|
cv.Optional(CONF_IO_CAPABILITY, default="none"): cv.enum(
|
54
57
|
IO_CAPABILITY, lower=True
|
55
58
|
),
|
@@ -67,7 +70,22 @@ def validate_variant(_):
|
|
67
70
|
raise cv.Invalid(f"{variant} does not support Bluetooth")
|
68
71
|
|
69
72
|
|
70
|
-
|
73
|
+
def final_validation(config):
|
74
|
+
validate_variant(config)
|
75
|
+
if (name := config.get(CONF_NAME)) is not None:
|
76
|
+
full_config = fv.full_config.get()
|
77
|
+
max_length = 20
|
78
|
+
if full_config[CONF_ESPHOME][CONF_NAME_ADD_MAC_SUFFIX]:
|
79
|
+
max_length -= 7 # "-AABBCC" is appended when add mac suffix option is used
|
80
|
+
if len(name) > max_length:
|
81
|
+
raise cv.Invalid(
|
82
|
+
f"Name '{name}' is too long, maximum length is {max_length} characters"
|
83
|
+
)
|
84
|
+
|
85
|
+
return config
|
86
|
+
|
87
|
+
|
88
|
+
FINAL_VALIDATE_SCHEMA = final_validation
|
71
89
|
|
72
90
|
|
73
91
|
async def to_code(config):
|
@@ -75,6 +93,8 @@ async def to_code(config):
|
|
75
93
|
cg.add(var.set_enable_on_boot(config[CONF_ENABLE_ON_BOOT]))
|
76
94
|
cg.add(var.set_io_capability(config[CONF_IO_CAPABILITY]))
|
77
95
|
cg.add(var.set_advertising_cycle_time(config[CONF_ADVERTISING_CYCLE_TIME]))
|
96
|
+
if (name := config.get(CONF_NAME)) is not None:
|
97
|
+
cg.add(var.set_name(name))
|
78
98
|
await cg.register_component(var, config)
|
79
99
|
|
80
100
|
if CORE.using_esp_idf:
|
@@ -27,6 +27,9 @@ namespace esp32_ble {
|
|
27
27
|
|
28
28
|
static const char *const TAG = "esp32_ble";
|
29
29
|
|
30
|
+
static RAMAllocator<BLEEvent> EVENT_ALLOCATOR( // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
31
|
+
RAMAllocator<BLEEvent>::ALLOW_FAILURE | RAMAllocator<BLEEvent>::ALLOC_INTERNAL);
|
32
|
+
|
30
33
|
void ESP32BLE::setup() {
|
31
34
|
global_ble = this;
|
32
35
|
ESP_LOGCONFIG(TAG, "Setting up BLE...");
|
@@ -188,12 +191,20 @@ bool ESP32BLE::ble_setup_() {
|
|
188
191
|
}
|
189
192
|
}
|
190
193
|
|
191
|
-
std::string name
|
192
|
-
if (
|
194
|
+
std::string name;
|
195
|
+
if (this->name_.has_value()) {
|
196
|
+
name = this->name_.value();
|
193
197
|
if (App.is_name_add_mac_suffix_enabled()) {
|
194
|
-
name
|
195
|
-
}
|
196
|
-
|
198
|
+
name += "-" + get_mac_address().substr(6);
|
199
|
+
}
|
200
|
+
} else {
|
201
|
+
name = App.get_name();
|
202
|
+
if (name.length() > 20) {
|
203
|
+
if (App.is_name_add_mac_suffix_enabled()) {
|
204
|
+
name.erase(name.begin() + 13, name.end() - 7); // Remove characters between 13 and the mac address
|
205
|
+
} else {
|
206
|
+
name = name.substr(0, 20);
|
207
|
+
}
|
197
208
|
}
|
198
209
|
}
|
199
210
|
|
@@ -314,7 +325,8 @@ void ESP32BLE::loop() {
|
|
314
325
|
default:
|
315
326
|
break;
|
316
327
|
}
|
317
|
-
|
328
|
+
ble_event->~BLEEvent();
|
329
|
+
EVENT_ALLOCATOR.deallocate(ble_event, 1);
|
318
330
|
ble_event = this->ble_events_.pop();
|
319
331
|
}
|
320
332
|
if (this->advertising_ != nullptr) {
|
@@ -323,9 +335,14 @@ void ESP32BLE::loop() {
|
|
323
335
|
}
|
324
336
|
|
325
337
|
void ESP32BLE::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) {
|
326
|
-
BLEEvent *new_event =
|
338
|
+
BLEEvent *new_event = EVENT_ALLOCATOR.allocate(1);
|
339
|
+
if (new_event == nullptr) {
|
340
|
+
// Memory too fragmented to allocate new event. Can only drop it until memory comes back
|
341
|
+
return;
|
342
|
+
}
|
343
|
+
new (new_event) BLEEvent(event, param);
|
327
344
|
global_ble->ble_events_.push(new_event);
|
328
|
-
} // NOLINT(clang-analyzer-
|
345
|
+
} // NOLINT(clang-analyzer-unix.Malloc)
|
329
346
|
|
330
347
|
void ESP32BLE::real_gap_event_handler_(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) {
|
331
348
|
ESP_LOGV(TAG, "(BLE) gap_event_handler - %d", event);
|
@@ -336,9 +353,14 @@ void ESP32BLE::real_gap_event_handler_(esp_gap_ble_cb_event_t event, esp_ble_gap
|
|
336
353
|
|
337
354
|
void ESP32BLE::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
|
338
355
|
esp_ble_gatts_cb_param_t *param) {
|
339
|
-
BLEEvent *new_event =
|
356
|
+
BLEEvent *new_event = EVENT_ALLOCATOR.allocate(1);
|
357
|
+
if (new_event == nullptr) {
|
358
|
+
// Memory too fragmented to allocate new event. Can only drop it until memory comes back
|
359
|
+
return;
|
360
|
+
}
|
361
|
+
new (new_event) BLEEvent(event, gatts_if, param);
|
340
362
|
global_ble->ble_events_.push(new_event);
|
341
|
-
} // NOLINT(clang-analyzer-
|
363
|
+
} // NOLINT(clang-analyzer-unix.Malloc)
|
342
364
|
|
343
365
|
void ESP32BLE::real_gatts_event_handler_(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
|
344
366
|
esp_ble_gatts_cb_param_t *param) {
|
@@ -350,9 +372,14 @@ void ESP32BLE::real_gatts_event_handler_(esp_gatts_cb_event_t event, esp_gatt_if
|
|
350
372
|
|
351
373
|
void ESP32BLE::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
|
352
374
|
esp_ble_gattc_cb_param_t *param) {
|
353
|
-
BLEEvent *new_event =
|
375
|
+
BLEEvent *new_event = EVENT_ALLOCATOR.allocate(1);
|
376
|
+
if (new_event == nullptr) {
|
377
|
+
// Memory too fragmented to allocate new event. Can only drop it until memory comes back
|
378
|
+
return;
|
379
|
+
}
|
380
|
+
new (new_event) BLEEvent(event, gattc_if, param);
|
354
381
|
global_ble->ble_events_.push(new_event);
|
355
|
-
} // NOLINT(clang-analyzer-
|
382
|
+
} // NOLINT(clang-analyzer-unix.Malloc)
|
356
383
|
|
357
384
|
void ESP32BLE::real_gattc_event_handler_(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
|
358
385
|
esp_ble_gattc_cb_param_t *param) {
|
@@ -90,6 +90,7 @@ class ESP32BLE : public Component {
|
|
90
90
|
void loop() override;
|
91
91
|
void dump_config() override;
|
92
92
|
float get_setup_priority() const override;
|
93
|
+
void set_name(const std::string &name) { this->name_ = name; }
|
93
94
|
|
94
95
|
void advertising_start();
|
95
96
|
void advertising_set_service_data(const std::vector<uint8_t> &data);
|
@@ -131,6 +132,7 @@ class ESP32BLE : public Component {
|
|
131
132
|
esp_ble_io_cap_t io_cap_{ESP_IO_CAP_NONE};
|
132
133
|
uint32_t advertising_cycle_time_;
|
133
134
|
bool enable_on_boot_;
|
135
|
+
optional<std::string> name_;
|
134
136
|
};
|
135
137
|
|
136
138
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
@@ -83,7 +83,7 @@ esp_err_t BLEAdvertising::services_advertisement_() {
|
|
83
83
|
esp_err_t err;
|
84
84
|
|
85
85
|
this->advertising_data_.set_scan_rsp = false;
|
86
|
-
this->advertising_data_.include_name =
|
86
|
+
this->advertising_data_.include_name = true;
|
87
87
|
this->advertising_data_.include_txpower = !this->scan_response_;
|
88
88
|
err = esp_ble_gap_config_adv_data(&this->advertising_data_);
|
89
89
|
if (err != ESP_OK) {
|
@@ -34,7 +34,7 @@ ESPBTUUID ESPBTUUID::from_raw(const uint8_t *data) {
|
|
34
34
|
ESPBTUUID ESPBTUUID::from_raw_reversed(const uint8_t *data) {
|
35
35
|
ESPBTUUID ret;
|
36
36
|
ret.uuid_.len = ESP_UUID_LEN_128;
|
37
|
-
for (
|
37
|
+
for (uint8_t i = 0; i < ESP_UUID_LEN_128; i++)
|
38
38
|
ret.uuid_.uuid.uuid128[ESP_UUID_LEN_128 - 1 - i] = data[i];
|
39
39
|
return ret;
|
40
40
|
}
|
@@ -43,30 +43,30 @@ ESPBTUUID ESPBTUUID::from_raw(const std::string &data) {
|
|
43
43
|
if (data.length() == 4) {
|
44
44
|
ret.uuid_.len = ESP_UUID_LEN_16;
|
45
45
|
ret.uuid_.uuid.uuid16 = 0;
|
46
|
-
for (
|
46
|
+
for (uint i = 0; i < data.length(); i += 2) {
|
47
47
|
uint8_t msb = data.c_str()[i];
|
48
48
|
uint8_t lsb = data.c_str()[i + 1];
|
49
|
+
uint8_t lsb_shift = i <= 2 ? (2 - i) * 4 : 0;
|
49
50
|
|
50
51
|
if (msb > '9')
|
51
52
|
msb -= 7;
|
52
53
|
if (lsb > '9')
|
53
54
|
lsb -= 7;
|
54
|
-
ret.uuid_.uuid.uuid16 += (((msb & 0x0F) << 4) | (lsb & 0x0F)) <<
|
55
|
-
i += 2;
|
55
|
+
ret.uuid_.uuid.uuid16 += (((msb & 0x0F) << 4) | (lsb & 0x0F)) << lsb_shift;
|
56
56
|
}
|
57
57
|
} else if (data.length() == 8) {
|
58
58
|
ret.uuid_.len = ESP_UUID_LEN_32;
|
59
59
|
ret.uuid_.uuid.uuid32 = 0;
|
60
|
-
for (
|
60
|
+
for (uint i = 0; i < data.length(); i += 2) {
|
61
61
|
uint8_t msb = data.c_str()[i];
|
62
62
|
uint8_t lsb = data.c_str()[i + 1];
|
63
|
+
uint8_t lsb_shift = i <= 6 ? (6 - i) * 4 : 0;
|
63
64
|
|
64
65
|
if (msb > '9')
|
65
66
|
msb -= 7;
|
66
67
|
if (lsb > '9')
|
67
68
|
lsb -= 7;
|
68
|
-
ret.uuid_.uuid.uuid32 += (((msb & 0x0F) << 4) | (lsb & 0x0F)) <<
|
69
|
-
i += 2;
|
69
|
+
ret.uuid_.uuid.uuid32 += (((msb & 0x0F) << 4) | (lsb & 0x0F)) << lsb_shift;
|
70
70
|
}
|
71
71
|
} else if (data.length() == 16) { // how we can have 16 byte length string reprezenting 128 bit uuid??? needs to be
|
72
72
|
// investigated (lack of time)
|
@@ -77,7 +77,7 @@ ESPBTUUID ESPBTUUID::from_raw(const std::string &data) {
|
|
77
77
|
// UUID format.
|
78
78
|
ret.uuid_.len = ESP_UUID_LEN_128;
|
79
79
|
int n = 0;
|
80
|
-
for (
|
80
|
+
for (uint i = 0; i < data.length(); i += 2) {
|
81
81
|
if (data.c_str()[i] == '-')
|
82
82
|
i++;
|
83
83
|
uint8_t msb = data.c_str()[i];
|
@@ -88,7 +88,6 @@ ESPBTUUID ESPBTUUID::from_raw(const std::string &data) {
|
|
88
88
|
if (lsb > '9')
|
89
89
|
lsb -= 7;
|
90
90
|
ret.uuid_.uuid.uuid128[15 - n++] = ((msb & 0x0F) << 4) | (lsb & 0x0F);
|
91
|
-
i += 2;
|
92
91
|
}
|
93
92
|
} else {
|
94
93
|
ESP_LOGE(TAG, "ERROR: UUID value not 2, 4, 16 or 36 bytes - %s", data.c_str());
|
@@ -155,7 +154,7 @@ bool ESPBTUUID::operator==(const ESPBTUUID &uuid) const {
|
|
155
154
|
}
|
156
155
|
break;
|
157
156
|
case ESP_UUID_LEN_128:
|
158
|
-
for (
|
157
|
+
for (uint8_t i = 0; i < ESP_UUID_LEN_128; i++) {
|
159
158
|
if (uuid.uuid_.uuid.uuid128[i] != this->uuid_.uuid.uuid128[i]) {
|
160
159
|
return false;
|
161
160
|
}
|
@@ -432,7 +432,7 @@ void ESPBTDevice::parse_scan_rst(const esp_ble_gap_cb_param_t::ble_scan_result_e
|
|
432
432
|
|
433
433
|
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
434
434
|
ESP_LOGVV(TAG, "Parse Result:");
|
435
|
-
const char *address_type
|
435
|
+
const char *address_type;
|
436
436
|
switch (this->address_type_) {
|
437
437
|
case BLE_ADDR_TYPE_PUBLIC:
|
438
438
|
address_type = "PUBLIC";
|
@@ -446,6 +446,9 @@ void ESPBTDevice::parse_scan_rst(const esp_ble_gap_cb_param_t::ble_scan_result_e
|
|
446
446
|
case BLE_ADDR_TYPE_RPA_RANDOM:
|
447
447
|
address_type = "RPA_RANDOM";
|
448
448
|
break;
|
449
|
+
default:
|
450
|
+
address_type = "UNKNOWN";
|
451
|
+
break;
|
449
452
|
}
|
450
453
|
ESP_LOGVV(TAG, " Address: %02X:%02X:%02X:%02X:%02X:%02X (%s)", this->address_[0], this->address_[1],
|
451
454
|
this->address_[2], this->address_[3], this->address_[4], this->address_[5], address_type);
|
@@ -1,9 +1,9 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
2
|
|
3
|
-
import esphome.codegen as cg
|
4
|
-
import esphome.config_validation as cv
|
5
3
|
from esphome import pins
|
4
|
+
import esphome.codegen as cg
|
6
5
|
from esphome.components import esp32_rmt, light
|
6
|
+
import esphome.config_validation as cv
|
7
7
|
from esphome.const import (
|
8
8
|
CONF_CHIPSET,
|
9
9
|
CONF_IS_RGBW,
|
@@ -103,7 +103,7 @@ CONFIG_SCHEMA = cv.All(
|
|
103
103
|
default="0 us",
|
104
104
|
): cv.positive_time_period_nanoseconds,
|
105
105
|
}
|
106
|
-
),
|
106
|
+
).extend(cv.COMPONENT_SCHEMA),
|
107
107
|
cv.has_exactly_one_key(CONF_CHIPSET, CONF_BIT0_HIGH),
|
108
108
|
)
|
109
109
|
|
@@ -1,10 +1,13 @@
|
|
1
1
|
import logging
|
2
2
|
import os
|
3
3
|
|
4
|
+
import esphome.codegen as cg
|
5
|
+
import esphome.config_validation as cv
|
4
6
|
from esphome.const import (
|
5
7
|
CONF_BOARD,
|
6
8
|
CONF_BOARD_FLASH_MODE,
|
7
9
|
CONF_FRAMEWORK,
|
10
|
+
CONF_PLATFORM_VERSION,
|
8
11
|
CONF_SOURCE,
|
9
12
|
CONF_VERSION,
|
10
13
|
KEY_CORE,
|
@@ -12,27 +15,22 @@ from esphome.const import (
|
|
12
15
|
KEY_TARGET_FRAMEWORK,
|
13
16
|
KEY_TARGET_PLATFORM,
|
14
17
|
PLATFORM_ESP8266,
|
15
|
-
CONF_PLATFORM_VERSION,
|
16
18
|
)
|
17
19
|
from esphome.core import CORE, coroutine_with_priority
|
18
|
-
import esphome.config_validation as cv
|
19
|
-
import esphome.codegen as cg
|
20
20
|
from esphome.helpers import copy_file_if_changed
|
21
21
|
|
22
|
+
from .boards import BOARDS, ESP8266_LD_SCRIPTS
|
22
23
|
from .const import (
|
23
|
-
CONF_RESTORE_FROM_FLASH,
|
24
24
|
CONF_EARLY_PIN_INIT,
|
25
|
+
CONF_RESTORE_FROM_FLASH,
|
25
26
|
KEY_BOARD,
|
26
27
|
KEY_ESP8266,
|
27
28
|
KEY_FLASH_SIZE,
|
28
29
|
KEY_PIN_INITIAL_STATES,
|
29
30
|
esp8266_ns,
|
30
31
|
)
|
31
|
-
from .boards import BOARDS, ESP8266_LD_SCRIPTS
|
32
|
-
|
33
32
|
from .gpio import PinInitialState, add_pin_initial_states_array
|
34
33
|
|
35
|
-
|
36
34
|
CODEOWNERS = ["@esphome/core"]
|
37
35
|
_LOGGER = logging.getLogger(__name__)
|
38
36
|
AUTO_LOAD = ["preferences"]
|
esphome/components/ezo/ezo.cpp
CHANGED
@@ -111,11 +111,11 @@ void EZOSensor::loop() {
|
|
111
111
|
if (buf[0] == 1) {
|
112
112
|
std::string payload = reinterpret_cast<char *>(&buf[1]);
|
113
113
|
if (!payload.empty()) {
|
114
|
+
auto start_location = payload.find(',');
|
114
115
|
switch (to_run->command_type) {
|
115
116
|
case EzoCommandType::EZO_READ: {
|
116
117
|
// some sensors return multiple comma-separated values, terminate string after first one
|
117
|
-
|
118
|
-
if ((start_location = payload.find(',')) != std::string::npos) {
|
118
|
+
if (start_location != std::string::npos) {
|
119
119
|
payload.erase(start_location);
|
120
120
|
}
|
121
121
|
auto val = parse_number<float>(payload);
|
@@ -126,49 +126,37 @@ void EZOSensor::loop() {
|
|
126
126
|
}
|
127
127
|
break;
|
128
128
|
}
|
129
|
-
case EzoCommandType::EZO_LED:
|
129
|
+
case EzoCommandType::EZO_LED:
|
130
130
|
this->led_callback_.call(payload.back() == '1');
|
131
131
|
break;
|
132
|
-
|
133
|
-
|
134
|
-
int start_location = 0;
|
135
|
-
if ((start_location = payload.find(',')) != std::string::npos) {
|
132
|
+
case EzoCommandType::EZO_DEVICE_INFORMATION:
|
133
|
+
if (start_location != std::string::npos) {
|
136
134
|
this->device_infomation_callback_.call(payload.substr(start_location + 1));
|
137
135
|
}
|
138
136
|
break;
|
139
|
-
|
140
|
-
|
141
|
-
int start_location = 0;
|
142
|
-
if ((start_location = payload.find(',')) != std::string::npos) {
|
137
|
+
case EzoCommandType::EZO_SLOPE:
|
138
|
+
if (start_location != std::string::npos) {
|
143
139
|
this->slope_callback_.call(payload.substr(start_location + 1));
|
144
140
|
}
|
145
141
|
break;
|
146
|
-
|
147
|
-
|
148
|
-
int start_location = 0;
|
149
|
-
if ((start_location = payload.find(',')) != std::string::npos) {
|
142
|
+
case EzoCommandType::EZO_CALIBRATION:
|
143
|
+
if (start_location != std::string::npos) {
|
150
144
|
this->calibration_callback_.call(payload.substr(start_location + 1));
|
151
145
|
}
|
152
146
|
break;
|
153
|
-
|
154
|
-
|
155
|
-
int start_location = 0;
|
156
|
-
if ((start_location = payload.find(',')) != std::string::npos) {
|
147
|
+
case EzoCommandType::EZO_T:
|
148
|
+
if (start_location != std::string::npos) {
|
157
149
|
this->t_callback_.call(payload.substr(start_location + 1));
|
158
150
|
}
|
159
151
|
break;
|
160
|
-
|
161
|
-
case EzoCommandType::EZO_CUSTOM: {
|
152
|
+
case EzoCommandType::EZO_CUSTOM:
|
162
153
|
this->custom_callback_.call(payload);
|
163
154
|
break;
|
164
|
-
|
165
|
-
default: {
|
155
|
+
default:
|
166
156
|
break;
|
167
|
-
}
|
168
157
|
}
|
169
158
|
}
|
170
159
|
}
|
171
|
-
|
172
160
|
this->commands_.pop_front();
|
173
161
|
}
|
174
162
|
|
@@ -178,7 +166,7 @@ void EZOSensor::add_command_(const std::string &command, EzoCommandType command_
|
|
178
166
|
ezo_command->command_type = command_type;
|
179
167
|
ezo_command->delay_ms = delay_ms;
|
180
168
|
this->commands_.push_back(std::move(ezo_command));
|
181
|
-
}
|
169
|
+
}
|
182
170
|
|
183
171
|
void EZOSensor::set_calibration_point_(EzoCalibrationType type, float value) {
|
184
172
|
std::string payload = str_sprintf("Cal,%s,%0.2f", EZO_CALIBRATION_TYPE_STRINGS[type], value);
|
@@ -1,4 +1,3 @@
|
|
1
|
-
from collections.abc import Iterable
|
2
1
|
import functools
|
3
2
|
import hashlib
|
4
3
|
import logging
|
@@ -8,7 +7,6 @@ import re
|
|
8
7
|
|
9
8
|
import freetype
|
10
9
|
import glyphsets
|
11
|
-
from packaging import version
|
12
10
|
import requests
|
13
11
|
|
14
12
|
from esphome import core, external_files
|
@@ -53,8 +51,11 @@ CONF_IGNORE_MISSING_GLYPHS = "ignore_missing_glyphs"
|
|
53
51
|
# Cache loaded freetype fonts
|
54
52
|
class FontCache(dict):
|
55
53
|
def __missing__(self, key):
|
56
|
-
|
57
|
-
|
54
|
+
try:
|
55
|
+
res = self[key] = freetype.Face(key)
|
56
|
+
return res
|
57
|
+
except freetype.FT_Exception as e:
|
58
|
+
raise cv.Invalid(f"Could not load Font file {key}: {e}") from e
|
58
59
|
|
59
60
|
|
60
61
|
FONT_CACHE = FontCache()
|
@@ -88,7 +89,7 @@ def flatten(lists) -> list:
|
|
88
89
|
return list(chain.from_iterable(lists))
|
89
90
|
|
90
91
|
|
91
|
-
def check_missing_glyphs(file, codepoints
|
92
|
+
def check_missing_glyphs(file, codepoints, warning: bool = False):
|
92
93
|
"""
|
93
94
|
Check that the given font file actually contains the requested glyphs
|
94
95
|
:param file: A Truetype font file
|
@@ -177,24 +178,6 @@ def validate_glyphs(config):
|
|
177
178
|
return config
|
178
179
|
|
179
180
|
|
180
|
-
def validate_pillow_installed(value):
|
181
|
-
try:
|
182
|
-
import PIL
|
183
|
-
except ImportError as err:
|
184
|
-
raise cv.Invalid(
|
185
|
-
"Please install the pillow python package to use this feature. "
|
186
|
-
'(pip install "pillow==10.4.0")'
|
187
|
-
) from err
|
188
|
-
|
189
|
-
if version.parse(PIL.__version__) != version.parse("10.4.0"):
|
190
|
-
raise cv.Invalid(
|
191
|
-
"Please update your pillow installation to 10.4.0. "
|
192
|
-
'(pip install "pillow==10.4.0")'
|
193
|
-
)
|
194
|
-
|
195
|
-
return value
|
196
|
-
|
197
|
-
|
198
181
|
FONT_EXTENSIONS = (".ttf", ".woff", ".otf")
|
199
182
|
|
200
183
|
|
@@ -393,7 +376,9 @@ def font_file_schema(value):
|
|
393
376
|
# Default if no glyphs or glyphsets are provided
|
394
377
|
DEFAULT_GLYPHSET = "GF_Latin_Kernel"
|
395
378
|
# default for bitmap fonts
|
396
|
-
DEFAULT_GLYPHS =
|
379
|
+
DEFAULT_GLYPHS = (
|
380
|
+
' !"%()+=,-.:/?0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz°'
|
381
|
+
)
|
397
382
|
|
398
383
|
CONF_RAW_GLYPH_ID = "raw_glyph_id"
|
399
384
|
|
@@ -421,7 +406,7 @@ FONT_SCHEMA = cv.Schema(
|
|
421
406
|
},
|
422
407
|
)
|
423
408
|
|
424
|
-
CONFIG_SCHEMA = cv.All(
|
409
|
+
CONFIG_SCHEMA = cv.All(FONT_SCHEMA, validate_glyphs)
|
425
410
|
|
426
411
|
|
427
412
|
# PIL doesn't provide a consistent interface for both TrueType and bitmap
|
esphome/components/font/font.cpp
CHANGED
@@ -133,9 +133,11 @@ void Font::print(int x_start, int y_start, display::Display *display, Color colo
|
|
133
133
|
auto diff_r = (float) color.r - (float) background.r;
|
134
134
|
auto diff_g = (float) color.g - (float) background.g;
|
135
135
|
auto diff_b = (float) color.b - (float) background.b;
|
136
|
+
auto diff_w = (float) color.w - (float) background.w;
|
136
137
|
auto b_r = (float) background.r;
|
137
138
|
auto b_g = (float) background.g;
|
138
|
-
auto b_b = (float) background.
|
139
|
+
auto b_b = (float) background.b;
|
140
|
+
auto b_w = (float) background.w;
|
139
141
|
for (int glyph_y = y_start + scan_y1; glyph_y != max_y; glyph_y++) {
|
140
142
|
for (int glyph_x = x_at + scan_x1; glyph_x != max_x; glyph_x++) {
|
141
143
|
uint8_t pixel = 0;
|
@@ -153,8 +155,8 @@ void Font::print(int x_start, int y_start, display::Display *display, Color colo
|
|
153
155
|
display->draw_pixel_at(glyph_x, glyph_y, color);
|
154
156
|
} else if (pixel != 0) {
|
155
157
|
auto on = (float) pixel / (float) bpp_max;
|
156
|
-
auto blended =
|
157
|
-
|
158
|
+
auto blended = Color((uint8_t) (diff_r * on + b_r), (uint8_t) (diff_g * on + b_g),
|
159
|
+
(uint8_t) (diff_b * on + b_b), (uint8_t) (diff_w * on + b_w));
|
158
160
|
display->draw_pixel_at(glyph_x, glyph_y, blended);
|
159
161
|
}
|
160
162
|
}
|