Support for CAN Bus (Peak, Ixxat, canable etc)

Thank you for the feedback!
Unfortunately I just can’t get it working… Sorry…
Edit: Somehow it didn’t accept state but only `value_template’ instead.

I’ve added a template sensor to sensors.yaml:

- platform: template 
  sensors:
    dobiss:
      value_template: "dobiss"

I had to adapt the sensor.py script like you said to adjust to my messages.
Thank you so much already!!

Is it possible to create further template sensors based on this one sensor.dobiss?
Probably via:
value_template: '{{ states.sensor.dobiss["?"]["?"] }}' with the corresponding attributes?

But I can’t restart as it says:
The system cannot restart because the configuration is not valid: Invalid config for [sensor.template]: [state] is an invalid option for [sensor.template]. Check: sensor.template->sensors->dobiss->state. (See ?, line ?).

I can restart with
value_template: "dobiss"
but then the values don’t change when I receive a CAN message…

Offcourse, you can create sensors how you want, but you need to change the code offcourse to update other sensors

Hi Jojo,

please can you let me know how it is possible to install the can-until? Do you work here with Add-ons?
I don’t get the can-until installed…

Hi, this is not the place for those kinds of questions. Please PM me.

I’ve just spent few days playing with CAN / ESPHome and HomeAssistant and want to share some really promising results.

My test hardware:

  • two ESP32 modules with SN65HVD230 transceivers and step-down converters (modules are going to be powered from the bus itsef)
  • USB-CAN-A converter, compatible with seeedstudio interface from python-can

ESP32 modules are flashed with ESPHome firmware. I designed very simple, but extensible protocol for converting ESPHome entities to CAN frames. I also created few helper utility functions callable from ESPHome lambdas, for doing such conversion.

Another part is can2mqtt converter for exposing ESPHome CAN entities to HomeAssistant. It uses MQTT Auto-Discovery mechanism to automatically configure these entities in HA.

Source code of my can2mqtt gateway is here: GitHub - mrk-its/can2mqtt

It also contains example configuration of esphome device exposing through CAN three entities (sensor, binary_sensor and switch)

1 Like

Even though I think this has not so much to do with my initial idea of CAN bus integration into HA, I am happy to see your progress and that there are some more people out there interested in CAN bus at all :slight_smile: :+1: .

I was also thinking about automatically exposing CAN bus devices to HA by MQTT discovery. But that approach would be incompatible with my current solution, where I have an MQTT-to-CAN gateway that just translates both protocols into each other.

Because my initial idea of a native CAN bus integration is completely different from any “gateway” approach, I kindly ask you to continue this conversation via PM? I also have same questions regarding CAN bus in ESPhome and I would be happy if you were willing to help me :slight_smile: .

Greetings,
Jojo

will be possible to connect this Modul on RPI4 (where HA ist installed) to controll the CAN-Bus?
And if possible how to integrate it?

@Gandalph65 it looks it should be supported by python-can: [quick-guide] CAN bus on raspberry pi with MCP2515 and Arduino - Raspberry Pi Forums so can2mqtt shoud work

There are several tutorials how to connect this to the RPI and to make it appear and accessible as a “normal” CAN bus device. See the link from @mrk .
BUT: this will NOT be supported by HA ootb. Currently HA does not know anything about CAN bus → this is why this topic exists, feel free to vote). So you will still have to use tools to fill this gap between HA and CAN bus.

  • can2mqtt by @mrk is a pure software gateway
  • my own MQTT-to-CAN gateway is meant to run on an ESP8266 or ESP32
  • ESPhome also supports MCP2515 boards and ESP32 CAN

No native support in HA.

Remember, the can-usb devices are recognized in HassOS, drivers are included since I submitted them as a PR a while ago, so you can just use python-can

Hi everyone!

I’m new here and reading the whole discussion I got excited about the idea of having canbus at home, so I did some experiments that I’m sharing with you.

In the last weeks I experimented with the canbus using simple bluepill boards and I produced a simple firmware that allows me to manage 6 configurable output channels.
Later I created other canbus nodes:

  • A button node which controls the first channel of the relay board.
  • An esp866+MC2515 node with esphome acting as a “gateway” for Home Assistant.

I have also equipped the nodes with the customized configuration system, which allows me to configure each individual node via serial communication (in the future also via CAN) without the need to compile a code for each device.

I leave the relay board repository link if anyone wants to experiment: GitHub - cristiandc01/canbus_relay: This firmware allows you to create a configurable 6ch relay node controlled via canbus

1 Like

Hello, I can code in python, and I’m also interested in native CAN support for HA. If someone could catch me up on the progress so far, I think I can start coding.

1 Like

Well, can drivers for usb can adapters are already present… maybe a good start is to load the driver and open a connection based on different methods…
Next maybe a service to send can messages and sensors to receive messages?

Hi and welcome :tada: !
Well, on native support there has not been any progress afaik. I tried creating a new platform by myself with the help of the official developers tutorial, but I did not com very far because of missing knowledge in Python.
There are some interesting approaches in creating custom integrations as well as a rudimentary CANopen driver for ESPhome but as said no progress regarding native support.

What we have is a well working and stable Linux driver and a Python library that can interact with the kernels driver (see first post in this thread).
About how the new platform integration could look like I made a proposition here. I am quite familiar with CAN bus as well as with CANopen - but not with python. So although it was me who raised this topic, I am not sure how much I can contribute. I highly appreciate that you are willing to come onboard!
Cheers!

EDIT: And one more downer: there is not so much resonance in the community regarding CAN bus at all. So even if we manage to create a working integration, I don’t know how big the chance is that it will be merged into HA by the admins…

Hello every one.
At this moment I’m at the begin of developing my home automation and I also would like to implement all “network elements”, or at least most of them via CAN bus. Unfortunatelly at this moment I don’t really know ho to do it. May I ask you guys to share your knowledge with me? @Jojo-A How did you programmed ESP32 as an “gateway” you described in this topic? You wrote you have several CAN slaves communicating each other and one ESP32 as a translator to HOAS.

Do you know if HOAS already did some steps to native support of CAN bus? I didn’t find any mention yet.

Thank you in advance.

Hey @Sniker ,
welcome onboard!

About my gateway: it is basically written from scratch in Arduino IDE. Because of lack of knowledge (and time) this solution is currently really inflexible: there is no continuous webserver so that MQTT and WiFi settings can not be changed on the fly, no OTA update, settings like CAN baudrate are hardcoded and so on.
To sum it up I would say it is far away from being “production-ready”. It works for me (which was my primary goal) and you will get it running, too. But it will not be as convenient as ESPhome or so.
The approach of @mrk is also really interesting and a little bit more convenient - as long as your CAN nodes are CANopen compatible and you need to run the can2mqtt conversion script on a system connected to the CANbus.

Sadly I heard nothing from @geodic , yet. So currently it seems that the HA devs are not yet very interested in implementing native CAN support - because the requests from the community seem not to be sufficient (dear HA devs, don’t get me wrong! You are doing an amazing job and I really appreciate your work! I totally understand, that you have to prioritize your work.).
So feel free to vote this up.

If you have specific questions please contact me via PM. This thread should be for discussion about the integration and/or to share ideas :slight_smile: .

Cheers

you need to run the can2mqtt conversion script on a system connected to the CANbus.

Direct connection of system running can2mqtt is no longer required (but still recommended) - I implemented recently tunneling of raw can frames via dedicated mqtt topic and virtual python-can adapter using this protocol, so one of the ESP nodes can expose CANbus over wifi/eth to system running can2mqtt.

Also: can2mqtt works now as HA add-on, so it is really simple to run it on supervised HA

Hey, this sounds awesome!
I still like my approach to have a fully transparent bidirectional gateway, because it is universal and does not care about the higher-level protocols.
But when having a CANopen-only environment your approach is indisputable the more convenient and flexible one!
My environment is CANopen-only. You really make me think to switch :wink: .

On the other hand: I maybe should ban you from this thread because your solution reduces the need to implement native CAN support into HA! No, just kidding… :joy: .

1 Like

Ah cool, I was running a custom component with a small piece of python code to capture canbus messages and create sensors… Will have a look on your addon