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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user