ESP Home How to use extended CAN id

Hi all,

I’m trying to use ESP Home to connect the Home Assistent to my Zehnder ComfoAir Q450. This device does have a CAN bus. When connecting the CAN bus to a PEAK USB Dongle, I figured out that the device is transmitting with 50 kbit/s and it is using the extended IDs (29 bit).

I found this Python script from Marco Hoyer which is giving me the description of the CAN messages that I read on the bus: https://github.com/marco-hoyer/zcan/blob/11ca2f9031dc49a692d7dd12b67c3531fd5991d4/src/main/python/zcan/mapping.py

I’ve used a ESP board with the MCP2515 Component connected, like it is described here: CAN bus — ESPHome. The configuration is tested with the PEAK USB Dongle and I do get the configured messages in my Home Assistent.

Now I want to change to the ComfoAir device and want to read the extended CAN ID, but I can not figure out how to define the extended ID, it keeps telling me that the CAN ID is missing. Does somebody now how I should configure the CAN ID 0x001E4041?

The ESP Home parser keeps giving me this error below. It looks like it can read the hex value, since in the error message, the hex value is converted to the correct decimal value. Am I missing an attribute in the configuration?

INFO ESPHome 2023.12.7
INFO Reading configuration /config/esphome/zehnder-comfoair-q450.yaml...
Failed config

canbus.mcp2515: [source <unicode string>:51]
  platform: mcp2515
  spi_id: CANSpi
  cs_pin: GPIO13
  can_id: 1
  bit_rate: 50kbps
  use_extended_id: True
  
  'can_id' is a required option for [on_frame].
  on_frame: 
    - 
      Unable to find action with the name 'can_id'.
      can_id: 1982529
      use extended_id: True
      then: 
        - lambda: |-
            if(x.size() > 0) {
              float speed = float(float((int((x[0])) + x[1])) * 255);
              id(speed_output_ventilator).publish_state(speed);
              ESP_LOGD("main", "Speed output ventilator received over can is %f", speed);
            }

This is my actual configuration

esphome:
  name: "zehnder-comfoair-q450"
  friendly_name: Zenhder ComfoAir Q450

esp32:
  board: nodemcu-32s
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "aSQeJ9PGaTf7C0jZTp/1nHuI5PgVc60Wa5pFtJo99zg="

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-ZehnderComfoAirQ450"
    password: "cMU5kzLjrxfA"

captive_portal:

sensor:
  - platform: template
    name: "Snelheid uitgang ventilator"
    id: speed_output_ventilator
    unit_of_measurement: rpm
    icon: ""
    state_class: "measurement"
    accuracy_decimals: 0
    

    
# SPI - single controller
spi:
  id: CANSpi
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

canbus:
  - platform: mcp2515
    spi_id: CANSpi
    cs_pin: GPIO13
    can_id: 1
    bit_rate: 50kbps
    use_extended_id: true
    on_frame:

    # Speed output ventilator
    - can_id: 0x001E4041
      use extended_id: true
      then:
        - lambda: |-
            if(x.size() > 0) {
              float speed = float(float((int((x[0])) + x[1])) * 255);
              id(speed_output_ventilator).publish_state(speed);
              ESP_LOGD("main", "Speed output ventilator received over can is %f", speed);
            }



Remove the dash - this is only required when you have multiple can_ids.

    on_frame:

    # Speed output ventilator
      can_id: 0x001E4041
      use extended_id: true
      then:
        - lambda: |-
            if(x.size() > 0) {
              float speed = float(float((int((x[0])) + x[1])) * 255);
              id(speed_output_ventilator).publish_state(speed);
              ESP_LOGD("main", "Speed output ventilator received over can is %f", speed);
            }

And welcome to the forums and the joys of yaml… :slight_smile:

Hi Daryl,

Thanks for your reply. I think I could definitly follow a tutorial about YAML, since I am not very familiar with it like JSON or XML. In this case it was not the YAML, since I was able to have correct working configuration with two CAN-IDs 0x100 and 0x200 and the PEAK USB Dongle.

After reviewing the configuration a couple of times, I figured out that I made a typo in the ‘use extended_id’. Here, one underscore is missing :-(. After adding the underscore, the configuration is accepted. Now I need to retrieve the messages from the real device. They are not coming yet, but that could be a physical connection problem. I will figure it out :slight_smile: