Recently I was working on project for easy-exposing ESPHome entities to HomeAssistant over CANBus.
The project is splitted onto two parts: esphome-canopen external_component for converting ESPHome entities into CAN nodes and can2mqtt bridge exposing these CAN nodes to HomeAssistant through MQTT server. It follows MQTT discovery protocol, so ESPHome CAN entities appear automatically in HomeAssistant.
I started with my custom CAN protocol, but recenty I moved to CANopen standard. It should enable interesting features in near future, like mapping any existing CANopen devices into HomeAssistant entities.
esphome-canopen should work with any CAN Bus controller supported by ESPHome, like built-in ESP32 controller or external MCP2515 (on ESP32 or 8266 boards)
Example esphome config converting ESP32 gpio switch entity into CANopen device looks like:
external_components:
- source: github://mrk-its/esphome-canopen
canbus:
- platform: esp32_can
id: can_bus
rx_pin: GPIO22
tx_pin: GPIO23
can_id: 0
bit_rate: 125kbps
canopen:
id: can_gate
canbus_id: can_bus
node_id: 1
entities:
- id: blue_led
index: 2
tpdo: 0
switch:
- platform: gpio
name: "Blue Led"
id: blue_led
internal: true
pin: 2
For now following entity types are supported: sensor
, binary_sensor
, switch
and cover
, more will be added as needed.