mirror of
https://github.com/esphome/esphome.git
synced 2025-11-16 23:05:46 +00:00
Expand uart.write tests (#11785)
This commit is contained in:
@@ -3,6 +3,8 @@ esphome:
|
|||||||
then:
|
then:
|
||||||
- uart.write: 'Hello World'
|
- uart.write: 'Hello World'
|
||||||
- uart.write: [0x00, 0x20, 0x42]
|
- uart.write: [0x00, 0x20, 0x42]
|
||||||
|
- uart.write: !lambda |-
|
||||||
|
return {0xAA, 0xBB, 0xCC};
|
||||||
|
|
||||||
uart:
|
uart:
|
||||||
- id: uart_uart
|
- id: uart_uart
|
||||||
@@ -46,6 +48,15 @@ switch:
|
|||||||
turn_on: "TURN_ON"
|
turn_on: "TURN_ON"
|
||||||
turn_off: "TURN_OFF"
|
turn_off: "TURN_OFF"
|
||||||
|
|
||||||
|
number:
|
||||||
|
- platform: template
|
||||||
|
name: "Test Number"
|
||||||
|
id: test_number
|
||||||
|
optimistic: true
|
||||||
|
min_value: 0
|
||||||
|
max_value: 100
|
||||||
|
step: 1
|
||||||
|
|
||||||
button:
|
button:
|
||||||
# Test uart button with array data
|
# Test uart button with array data
|
||||||
- platform: uart
|
- platform: uart
|
||||||
@@ -57,3 +68,10 @@ button:
|
|||||||
name: "UART Button String"
|
name: "UART Button String"
|
||||||
uart_id: uart_uart
|
uart_id: uart_uart
|
||||||
data: "BUTTON_PRESS"
|
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