Merge branch 'dev' into usb-uart

This commit is contained in:
Clyde Stubbs
2025-10-29 20:55:38 +10:00
committed by GitHub
130 changed files with 1333 additions and 723 deletions
+49
View File
@@ -3,3 +3,52 @@ esp32_ble_tracker:
ble_client:
- mac_address: 01:02:03:04:05:06
id: test_blec
on_connect:
- ble_client.ble_write:
id: test_blec
service_uuid: "abcd1234-abcd-1234-abcd-abcd12345678"
characteristic_uuid: "abcd1235-abcd-1234-abcd-abcd12345678"
value: !lambda |-
return std::vector<uint8_t>{0x01, 0x02, 0x03};
- ble_client.ble_write:
id: test_blec
service_uuid: "abcd1234-abcd-1234-abcd-abcd12345678"
characteristic_uuid: "abcd1235-abcd-1234-abcd-abcd12345678"
value: [0x04, 0x05, 0x06]
on_passkey_request:
- ble_client.passkey_reply:
id: test_blec
passkey: !lambda |-
return 123456;
- ble_client.passkey_reply:
id: test_blec
passkey: 654321
on_numeric_comparison_request:
- ble_client.numeric_comparison_reply:
id: test_blec
accept: !lambda |-
return true;
- ble_client.numeric_comparison_reply:
id: test_blec
accept: false
sensor:
- platform: ble_client
ble_client_id: test_blec
type: characteristic
id: test_sensor_lambda
name: "BLE Sensor with Lambda"
service_uuid: "abcd1234-abcd-1234-abcd-abcd12345678"
characteristic_uuid: "abcd1236-abcd-1234-abcd-abcd12345678"
lambda: |-
if (x.size() >= 2) {
return (float)(x[0] | (x[1] << 8)) / 100.0;
}
return NAN;
- platform: ble_client
ble_client_id: test_blec
type: characteristic
id: test_sensor_no_lambda
name: "BLE Sensor without Lambda"
service_uuid: "abcd1234-abcd-1234-abcd-abcd12345678"
characteristic_uuid: "abcd1237-abcd-1234-abcd-abcd12345678"
-45
View File
@@ -4,51 +4,6 @@ wifi:
ssid: MySSID
password: password1
esphome:
on_boot:
then:
- http_request.get:
url: https://esphome.io
request_headers:
Content-Type: application/json
collect_headers:
- age
on_error:
logger.log: "Request failed"
on_response:
then:
- logger.log:
format: "Response status: %d, Duration: %lu ms, age: %s"
args:
- response->status_code
- (long) response->duration_ms
- response->get_response_header("age").c_str()
- http_request.post:
url: https://esphome.io
request_headers:
Content-Type: application/json
json:
key: value
- http_request.send:
method: PUT
url: https://esphome.io
request_headers:
Content-Type: application/json
body: "Some data"
http_request:
useragent: esphome/tagreader
timeout: 10s
verify_ssl: ${verify_ssl}
script:
- id: does_not_compile
parameters:
api_url: string
then:
- http_request.get:
url: "http://google.com"
ota:
- platform: http_request
id: http_request_ota
@@ -31,6 +31,20 @@ esphome:
request_headers:
Content-Type: application/json
body: "Some data"
- http_request.post:
url: https://esphome.io
request_headers:
Content-Type: application/json
json:
key: value
capture_response: true
on_response:
then:
- logger.log:
format: "Captured response status: %d, Body: %s"
args:
- response->status_code
- body.c_str()
http_request:
useragent: esphome/tagreader
+31
View File
@@ -52,6 +52,19 @@ number:
widget: spinbox_id
id: lvgl_spinbox_number
name: LVGL Spinbox Number
- platform: template
id: test_brightness
name: "Test Brightness"
min_value: 0
max_value: 255
step: 1
optimistic: true
# Test lambda in automation accessing x parameter directly
# This is a real-world pattern from user configs
on_value:
- lambda: !lambda |-
// Direct use of x parameter in automation
ESP_LOGD("test", "Brightness: %.0f", x);
light:
- platform: lvgl
@@ -110,3 +123,21 @@ text:
platform: lvgl
widget: hello_label
mode: text
text_sensor:
- platform: template
id: test_text_sensor
name: "Test Text Sensor"
# Test nested lambdas in LVGL actions can access automation parameters
on_value:
- lvgl.label.update:
id: hello_label
text: !lambda return x.c_str();
- lvgl.label.update:
id: hello_label
text: !lambda |-
// Test complex lambda with conditionals accessing x parameter
if (x == "*") {
return "WILDCARD";
}
return x.c_str();
+23
View File
@@ -257,7 +257,30 @@ lvgl:
text: "Hello shiny day"
text_color: 0xFFFFFF
align: bottom_mid
- label:
id: setup_lambda_label
# Test lambda in widget property during setup (LvContext)
# Should NOT receive lv_component parameter
text: !lambda |-
char buf[32];
snprintf(buf, sizeof(buf), "Setup: %d", 42);
return std::string(buf);
align: top_mid
text_font: space16
- label:
id: chip_info_label
# Test complex setup lambda (real-world pattern)
# Should NOT receive lv_component parameter
text: !lambda |-
// Test conditional compilation and string formatting
char buf[64];
#ifdef USE_ESP_IDF
snprintf(buf, sizeof(buf), "IDF: v%d.%d", ESP_IDF_VERSION_MAJOR, ESP_IDF_VERSION_MINOR);
#else
snprintf(buf, sizeof(buf), "Arduino");
#endif
return std::string(buf);
align: top_left
- obj:
align: center
arc_opa: COVER
@@ -56,6 +56,14 @@ binary_sensor:
register_type: read
address: 0x3200
bitmask: 0x80
- platform: modbus_controller
modbus_controller_id: modbus_controller1
id: modbus_binary_sensor2
name: Test Binary Sensor with Lambda
register_type: read
address: 0x3201
lambda: |-
return x;
number:
- platform: modbus_controller
@@ -65,6 +73,16 @@ number:
address: 0x9001
value_type: U_WORD
multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_controller1
id: modbus_number2
name: Test Number with Lambda
address: 0x9002
value_type: U_WORD
lambda: |-
return x * 2.0;
write_lambda: |-
return x / 2.0;
output:
- platform: modbus_controller
@@ -74,6 +92,14 @@ output:
register_type: holding
value_type: U_WORD
multiply: 1000
- platform: modbus_controller
modbus_controller_id: modbus_controller1
id: modbus_output2
address: 2049
register_type: holding
value_type: U_WORD
write_lambda: |-
return x * 100.0;
select:
- platform: modbus_controller
@@ -87,6 +113,34 @@ select:
"One": 1
"Two": 2
"Three": 3
- platform: modbus_controller
modbus_controller_id: modbus_controller1
id: modbus_select2
name: Test Select with Lambda
address: 1001
value_type: U_WORD
optionsmap:
"Off": 0
"On": 1
"Two": 2
lambda: |-
ESP_LOGD("Reg1001", "Received value %lld", x);
if (x > 1) {
return std::string("Two");
} else if (x == 1) {
return std::string("On");
}
return std::string("Off");
write_lambda: |-
ESP_LOGD("Reg1001", "Set option to %s (%lld)", x.c_str(), value);
if (x == "On") {
return 1;
}
if (x == "Two") {
payload.push_back(0x0002);
return 0;
}
return value;
sensor:
- platform: modbus_controller
@@ -97,6 +151,15 @@ sensor:
address: 0x9001
unit_of_measurement: "AH"
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: modbus_controller1
id: modbus_sensor2
name: Test Sensor with Lambda
register_type: holding
address: 0x9002
value_type: U_WORD
lambda: |-
return x / 10.0;
switch:
- platform: modbus_controller
@@ -106,6 +169,16 @@ switch:
register_type: coil
address: 0x15
bitmask: 1
- platform: modbus_controller
modbus_controller_id: modbus_controller1
id: modbus_switch2
name: Test Switch with Lambda
register_type: coil
address: 0x16
lambda: |-
return !x;
write_lambda: |-
return !x;
text_sensor:
- platform: modbus_controller
@@ -117,3 +190,13 @@ text_sensor:
register_count: 3
raw_encode: HEXBYTES
response_size: 6
- platform: modbus_controller
modbus_controller_id: modbus_controller1
id: modbus_text_sensor2
name: Test Text Sensor with Lambda
register_type: holding
address: 0x9014
register_count: 2
response_size: 4
lambda: |-
return "Modified: " + x;
@@ -48,6 +48,11 @@ on_drayton:
- logger.log:
format: "on_drayton: %u %u %u"
args: ["x.address", "x.channel", "x.command"]
on_dyson:
then:
- logger.log:
format: "on_dyson: %u %u"
args: ["x.code", "x.index"]
on_gobox:
then:
- logger.log:
@@ -6,6 +6,13 @@ button:
remote_transmitter.transmit_beo4:
source: 0x01
command: 0x0C
- platform: template
name: Dyson fan up
id: dyson_fan_up
on_press:
remote_transmitter.transmit_dyson:
code: 0x1215
index: 0x0
- platform: template
name: JVC Off
id: living_room_lights_on
+38
View File
@@ -19,3 +19,41 @@ uart:
packet_transport:
- platform: uart
switch:
# Test uart switch with single state (array)
- platform: uart
name: "UART Switch Single Array"
uart_id: uart_uart
data: [0x01, 0x02, 0x03]
# Test uart switch with single state (string)
- platform: uart
name: "UART Switch Single String"
uart_id: uart_uart
data: "ON"
# Test uart switch with turn_on/turn_off (arrays)
- platform: uart
name: "UART Switch Dual Array"
uart_id: uart_uart
data:
turn_on: [0xA0, 0xA1, 0xA2]
turn_off: [0xB0, 0xB1, 0xB2]
# Test uart switch with turn_on/turn_off (strings)
- platform: uart
name: "UART Switch Dual String"
uart_id: uart_uart
data:
turn_on: "TURN_ON"
turn_off: "TURN_OFF"
button:
# Test uart button with array data
- platform: uart
name: "UART Button Array"
uart_id: uart_uart
data: [0xFF, 0xEE, 0xDD]
# Test uart button with string data
- platform: uart
name: "UART Button String"
uart_id: uart_uart
data: "BUTTON_PRESS"
@@ -13,3 +13,21 @@ uart:
rx_buffer_size: 512
parity: EVEN
stop_bits: 2
switch:
- platform: uart
name: "UART Switch Array"
uart_id: uart_uart
data: [0x01, 0x02, 0x03]
- platform: uart
name: "UART Switch Dual"
uart_id: uart_uart
data:
turn_on: [0xA0, 0xA1]
turn_off: [0xB0, 0xB1]
button:
- platform: uart
name: "UART Button"
uart_id: uart_uart
data: [0xFF, 0xEE]