Yes, hardware is not a big deal for CAN bus. IIRC there is even the possibility to connect a Standalone-CAN-Shield to the RPi (to the SPI pins) and it will appear as a native CAN interface on the RPi.
Your confusion about where to start might lead from the fact, that there is no “physical” bus master in a CAN bus network. Each node can drop a message to the bus which will then be received by all other nodes (ID filters are currently not in scope ).
So you can define the “logical” master by yourself - in most cases this is a PC or some kind of PLC with a CAN interface/dongle. In our case the master could be the system where HA is running on. BUT REMEMBER: there is currently NO native CAN bus support implemented in HA! That’s why we started this thread.
A step-by-step guide is not that easy. Either a device manufacturer uses a “standard” higher-level protocol (like CANopen) or he defines his own “protocol”.
In both cases it all comes down to two things: which identifier is used and what is the message content.
Example (from my current system): I went for a CAN communication that is close to CANopen. That means that I have two types messages:
so called SDOs, which I use to drop commands from my “master” to the nodes
so called PDOs which I use for my nodes to publish their process data / status information
My previous setup was similar. But I did not stick to the CANopen scheme with SDOs and PDOs. I just defined the IDs for each message by myself.
Example:
ID 0x100[n] contains temperature data, sent periodically from each node [1…n] to the master
ID 0x200[n] contains position data, sent periodically from each node [1…n] to the master
ID 0x110[n] contains positioning commands, sent from the master to the specific node [1…n]
…
But again: there is currently NO native CAN bus support implemented in HA! This means that everything regarding CAN bus will require programming by … well… you. Of course there are many “easy-to-use” projects out there for Arduino + CAN-bus-shield. But you will have to program the nodes behavior by yourself (because there are very rare CAN devices for home automation).
If you are willing (or actually able) to do the programming part I am very sure that you will get a CAN-based system running - it is not that hard. But without any programming skills it will be just harder .
I think your research would best be placed in its own topic in this forum. As @Jojo-A rightfully said it does not make sense to pollute this feature request with discussions about the optimum system for you to use.
You may leave a link here to your new topic once you created it. If you have specific questions re KNX you are also welcome to post them as comments to the KNX Cookbook guide in this forum.
This being said, I think that another option for you would be HA with ESPHome microcontroller nodes as user interfaces, sensors and actors. They can communicate based on WiFi. But if you wan’t them wired instead of WLAN based, this is also easily possible by using standard CAT-7 cabling with POE (Power-over-Ethernet) power supply. The only thing you have to decide now is the kind of cabling that you put into your walls. This will be very different for CAN, KNX and IP based systems. Different in terms of cable type and in terms of topology (line vs. star vs. mesh …). Everything else can be changed and improved later but the cabling is close to impossible to change once your house is built.
But as said: Better open up a dedicated thread for discussion.
Let me see if I understood.
Now you have in a cabinet a device [STM32F103 Dev Board with CAN bus transceiver and some IO port expanders] acting like one can bus client? And connected to that device you have electric roller shutters, door sensors, physical switches, lights, etc? And the CAN bus is connected with HA by a CAN-TO-MQTT Gateway based on ESP8266 device + MCP2515 via Wifi network. This gateway is running ESPHome or other code?
In that case If we press one physical switch, that system alone can tun on a light, so, it means that it’s not HA dependent, right? But the CAN message of that switch is sent to the CAN bus? And can be received by any connected device, including the gateway? This means you have a very specific software on the STM32F103 dev board?
Please tell me if can be done this way. Have a CAN bus client (ESP Home, ESP8266, STM32F103, etc), called ROOM-HUB, per room with all sensors, switches, roller shutters connected to the him?And connect all ROOM-HUBs to the same CAN bus and then have the CAN-to-MQTT gateway or in future the USB-to-CAN dongle?
That ROOM-HUB (CAN bus client) can be an ESPhome device?
Basically yes !
My CAN bus system is set up in a way that each node can still fulfill its purpose even without HA. Means That I can still open and close my window shutters even without any network at all . This way and is crucial for me - no exceptions (at least for the really important stuff like lights, windows and so on).
My HA instance is “just” the frontend to display data and to drop control commands. And as you correctly understood, this is actually done through my MQTT-to-CAN gateway (ESP8266+MCP2515) with own code.
And also correct is, that one could also use an USB-to-CAN dongle for that and a PC to process all the CAN traffic stuff). And at this point I wish that HA would natively support CAN devices so that we won’t need a detour over MQTT and ethernet/WiFi.
A possible HA component could then listen to a specific CAN ID instead of a MQTT topic.
The picture you’ve drawn is totally possible with CAN bus. No problem at all. Not with basic CAN nor with CANopen. The only drawback will be that you would have to write most of the node’s code by yourself (what I also do).
When I have time I could try to create a similar picture of my setup as well, just for clarification and documentation .
Hi, there is a can2usb support, that PR was a long time ago submitted in HassOS
I wrote an custom script to load the dongle and listen for traffic, I update my sensor, based on that traffic…
With shellcommand, with cansend, I send stuff to the bus
As discussed on Discord, I had it working both on an ESP8266 with WiFi as well as on an Arduino Uno with an ethernet shield. The MQTT libraries and the code for translating the messages forth and back was identical.
If I find the code and manage to tidy it up a little bit I can share it via github.
What is the hardware you are using to control the roller shutters? Any two relay board with snubber filter? I’m looking for something like Shelly 2.5 but wired (without wifi).
At the beginning I planned to use these very wide spread dirty-cheap relay modules as they can be found on Aliexpress and so on (two-channel because one channel for up and one for down).
But I was not happy with the fact that I design an own board but have to add another cheap-a** chinese module to it. So meanwhile I think I will design the relays directly into my node board. Doing so, I can either solder the relay directly onto my board or I can use a relay socket so that I could exchange the relays later on (if necessary).
As snubbers I will use premade modules (R+C+Varistor) which I will solder directly on my board.
Hey -
I have a boiler system which has a CAN interface which is used with a proprietary standard.
I want to read out everything on Home Assistant and possible alter variables e.t.c.
The manufacturers Estyma, also do some really nice cheap boiler controls, and whilst I was originally planning to implement controls in KNX, if I could talk to their CAN system using Home Assistant, I’d be tempted to use their CAN bits, which are really good value.
Obviously there are cheaper ways out of this with homebrew stuff, but this is an off-the-shelf robust solution, and time is also a factor…
There are a couple of homebrew projects, where they have written Python code to build devices that will interface with the CAN code of the boiler controls… I think I am probably out of my depth and it would be worth trying to find someone to pay to write something to take the output from the boiler and translate it into home assistant usable form, but the fact that someone has reverse engineered the protocol, or obtained it, as it is proprietary and is using it in another project gives me hope that it can be done, even if I don’t quite have the skills to do it:
Kematics Pelle project looks promising…
The project has a good Wiki on the CAN protocol:
Another project here:
Any idea where to start on this! Anyone interested in taking it on as a job?
I think this is a good approach. ESPHome already talks CAN. I have a setup like this running for our car. Works nicely. Even if you want to use CAN as your home automation bus, this is a great solution. You don’t have to connect your bus wire physically to your Home Assistant hardware. Instead you use an ESP as a bridge and put it wherever your bus is accessible. You can even create multiple bus lines that are not directly connected (i.e. in different parts of the house). The needed hardware is extremely cheap.
Hm, on the one hand I agree with you because of exactly the arguments you mentioned.
On the other hand: what do one expect from HA? If we say that the (physical) interface support should happen on totally independent external projects (like ESPhome), HA will only be a frontend with an API.
I think this should not be the claim of HA - it already supports interfaces natively (Serial, Modbus). Why not CAN bus as well? Most stuff (arbitration, error handling, etc…) is handled by the Linux driver or by the python-can library. So on HA side it would be “only” ID and data handling.
I know that HA can not support every manufacturer-specific interface OOTB/natively. But CAN bus is kind of standard like Modbus.
Other thing to be taken into account then relaying on “external” projects:
the user has to take additional steps to get it working (set up an ESP-board, including programming, soldering…)
problems can be either on HA-side or an the other side (ESPhome). So where to report? Who will be willing to help?
what if a community-driven project like ESPhome is canceled?
when HA develops to be only a frontend for external integrations, HA won’t be able to run in a stand-alone environment.
@Jpsy I agree with your points! These points are definitely one of the advantages when one wants to de-centralize a system.
But my concerns from above will still remain. And it looks to me as if this becomes more a political as a technical decision
Just read about the ”WiCAN” crowdfunding campaign from MeatPi Electronics on Crowd Supply for an an open source ESP32-C3 based CAN adapters with either USB or OBD-II/OBD2 in (addition to Wi-Fi and BLE support) which made me want to request for an integration based on python-can or similar?
I started investigating into the topic of CAN-bus as part of my home automation and think the idea is still great.
I bought a Canable USB-to-CAN from Aliexpress and flashed the original firmware from canable.io → Candlelight, so gs-usb onto it.
When connecting it to a spare raspberry pi with raspbian, I see the interface with ip link list, but in Home Assistant (running with Home-Assistant OS on another raspberry pi), I can’t see the interface.
I thought after your PR, that all the modprobes are activated or do I miss something here?
What is needed to get the canable running on Home Assistant OS?
Do I have to activate some additional drivers? If yes, where to put the configs?
I hope this topic is still being worked on, as I think the option to have Home Assistant with CAN bus is really interesting, especially as an alternative to KNX.
As far as I’ve done my research, there is no real “wired” alternative to KNX available, which is a possibility for further USP.
Hi, no the PR was only to include the driver support for different type of can adapters
You still need to modprobe it…
I do it in a python script that i load with a custom component, you can do it for example in an automation on startup HA
Btw, i use SLCAN firmware on it, i had better experience with it
if you use candlelight firmware, then i dont think you need to use the slcand/ifconfig commands, but i believe you still need to modprobe it
you also see i do the canutils.apk manually, i do for tools like candump, cansend etc…
seems canutils is not part of the edge alpine main repo, only from the community