diff --git a/components/canbus.rst b/components/canbus.rst index 5e6c2b806..86e1fd11c 100644 --- a/components/canbus.rst +++ b/components/canbus.rst @@ -83,16 +83,17 @@ Configuration variables: Automations: ------------ -- **on_frame** (*Optional*, :ref:`Automation `): An automation to perform when ability - CAN Frame is received. See :ref:`canbus-on-frame`. +- **on_frame** (*Optional*, :ref:`Automation `): An automation to perform when a + CAN frame is received. See :ref:`canbus-on-frame`. .. _canbus-on-frame: ``on_frame`` ************ -This automation will be triggered when a can frame is received. A variable ``x`` of type -``std::vector`` is passed to the automation for use in lambdas. +This automation will be triggered when a CAN frame is received. A variable ``x`` of type +``std::vector`` containing the frame data and a variable ``can_id`` of type ``uint32_t`` +containing the actual received CAN id are passed to the automation for use in lambdas. .. note:: @@ -110,6 +111,34 @@ This automation will be triggered when a can frame is received. A variable ``x` lambda: 'return (x.size() > 0) ? x[0] == 0x11 : false;' then: light.toggle: light1 + - 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; + // to be continued... + } + + +Configuration variables: +************************ + +- **can_id** (**Required**, int): The received CAN id to trigger this automation on. +- **can_id_mask** (*Optional*, int): The bit mask to apply to the received CAN id before trying to match it + with *can_id*, defaults to ``0x1fffffff`` (all bits of received CAN id are compared with *can_id*). +- **use_extended_id** (*Optional*, boolean): Identifies the type of *can_id* to match on, defaults to *false*. ``canbus.send`` Action ********************** @@ -144,6 +173,8 @@ Configuration variables: the can bus device. - **use_extended_id** (*Optional*, boolean): default *false* identifies the type of *can_id*: *false*: Standard 11 Bit IDs, *true*: Extended 29Bit ID +- **remote_transmission_request** (*Optional*, boolean): Set to send CAN bus frame to request data from another node + (defaults to *false*). If a certain data length code needs to be sent, provide as many (dummy) bytes in *data*. ESP32 CAN Component -------------------