[canbus] Cover shared, string and trigger argument send payloads in the component tests (#20306)

This commit is contained in:
J. Nick Koston
2026-10-07 16:43:34 -10:00
committed by GitHub
parent 42edfe0681
commit 640ef1bb17
2 changed files with 28 additions and 0 deletions
+4
View File
@@ -18,6 +18,7 @@ canbus:
lambda: "return x[0] == 0x11;"
then:
logger.log: Truth
- canbus.send: !lambda return x;
- can_id: 0b00000000000000000000001000000
can_id_mask: 0b11111000000000011111111000000
use_extended_id: true
@@ -59,6 +60,9 @@ button:
data: [0, 1, 2]
- canbus.send: "abc"
- canbus.send: [0, 1, 2]
# Identical on purpose: both sends share one constant payload
- canbus.send: [0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88]
- canbus.send: [0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88]
- canbus.send: !lambda return {0, 1, 2};
# Test canbus.send with lambda that references a component (function pointer)
- canbus.send: !lambda |-
+24
View File
@@ -10,6 +10,11 @@ canbus:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can_id 500", "%s", b.c_str());
- canbus.send:
canbus_id: mcp2515_can
can_id: 501
data: !lambda |-
return {static_cast<uint8_t>(can_id), x.empty() ? uint8_t(0) : x[0]};
- can_id: 23
then:
- if:
@@ -36,3 +41,22 @@ canbus:
break;
// to be continued...
}
button:
- platform: template
name: MCP2515 Send
on_press:
# Identical on purpose: both sends share one constant payload
- canbus.send:
canbus_id: mcp2515_can
data: [0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88]
- canbus.send:
canbus_id: mcp2515_can
data: [0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88]
- canbus.send:
canbus_id: mcp2515_can
can_id: 0x123
data: "abc"
- canbus.send:
canbus_id: mcp2515_can
data: !lambda return {0x01, 0x02};