1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-09 19:41:49 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
J. Nick Koston
c5014321a6 Expand uart.write tests 2025-11-08 21:15:28 -06:00
2 changed files with 18 additions and 18 deletions

View File

@@ -1,12 +1,3 @@
number:
- platform: template
name: "Speaker Number"
id: my_number
optimistic: true
min_value: 0
max_value: 100
step: 1
esphome:
on_boot:
then:
@@ -23,15 +14,6 @@ esphome:
- speaker.finish:
- speaker.stop:
button:
- platform: template
name: "Speaker Button"
on_press:
then:
- speaker.play: [0x10, 0x20, 0x30, 0x40]
- speaker.play: !lambda |-
return {0x01, 0x02, (uint8_t)id(my_number).state};
i2s_audio:
i2s_lrclk_pin: ${i2s_bclk_pin}
i2s_bclk_pin: ${i2s_lrclk_pin}

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());