mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 08:15:49 +00:00
60 lines
1.6 KiB
YAML
60 lines
1.6 KiB
YAML
canbus:
|
|
- platform: esp32_can
|
|
id: esp32_internal_can
|
|
rx_pin: 4
|
|
tx_pin: 5
|
|
can_id: 4
|
|
bit_rate: 50kbps
|
|
on_frame:
|
|
- can_id: 500
|
|
then:
|
|
- lambda: |-
|
|
std::string b(x.begin(), x.end());
|
|
ESP_LOGD("canid 500", "%s", b.c_str());
|
|
- can_id: 23
|
|
then:
|
|
- if:
|
|
condition:
|
|
lambda: "return x[0] == 0x11;"
|
|
then:
|
|
logger.log: Truth
|
|
- can_id: 0b00000000000000000000001000000
|
|
can_id_mask: 0b11111000000000011111111000000
|
|
use_extended_id: true
|
|
then:
|
|
- lambda: |-
|
|
auto pdo_id = can_id >> 14;
|
|
switch (pdo_id)
|
|
{
|
|
case 117:
|
|
ESP_LOGD("canbus", "exhaust_fan_duty");
|
|
break;
|
|
case 118:
|
|
ESP_LOGD("canbus", "supply_fan_duty");
|
|
break;
|
|
case 119:
|
|
ESP_LOGD("canbus", "supply_fan_flow");
|
|
break;
|
|
}
|
|
|
|
number:
|
|
- platform: template
|
|
name: "Test Number"
|
|
id: test_number
|
|
optimistic: true
|
|
min_value: 0
|
|
max_value: 255
|
|
step: 1
|
|
|
|
button:
|
|
- platform: template
|
|
name: Canbus Actions
|
|
on_press:
|
|
- canbus.send: "abc"
|
|
- canbus.send: [0, 1, 2]
|
|
- canbus.send: !lambda return {0, 1, 2};
|
|
# Test canbus.send with lambda that references a component (function pointer)
|
|
- canbus.send: !lambda |-
|
|
uint8_t val = (uint8_t)id(test_number).state;
|
|
return std::vector<uint8_t>{0xAA, val, 0xBB};
|