1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-16 06:45:48 +00:00

Expand uart.write tests (#11785)

This commit is contained in:
J. Nick Koston
2025-11-09 16:09:03 -06:00
committed by GitHub
parent b61027607f
commit a290b88cd6

View File

@@ -3,6 +3,8 @@ esphome:
then:
- uart.write: 'Hello World'
- uart.write: [0x00, 0x20, 0x42]
- uart.write: !lambda |-
return {0xAA, 0xBB, 0xCC};
uart:
- id: uart_uart
@@ -46,6 +48,15 @@ switch:
turn_on: "TURN_ON"
turn_off: "TURN_OFF"
number:
- platform: template
name: "Test Number"
id: test_number
optimistic: true
min_value: 0
max_value: 100
step: 1
button:
# Test uart button with array data
- platform: uart
@@ -57,3 +68,10 @@ button:
name: "UART Button String"
uart_id: uart_uart
data: "BUTTON_PRESS"
# Test uart button with lambda (function pointer)
- platform: template
name: "UART Lambda Test"
on_press:
- uart.write: !lambda |-
std::string cmd = "VALUE=" + str_sprintf("%.0f", id(test_number).state) + "\r\n";
return std::vector<uint8_t>(cmd.begin(), cmd.end());