Skip to content

About

ESPhome component for Technische Alternative CAN-bus communication

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

Technische Alternative component for esphome

This component allows you to use an ESPHome device to emulate Technische Alternative nodes on a CAN bus.

Use it as external component

external_components:
  - source:
      type: git
      url: https://c0d3.sh/smarthome/esphome-ta.git
      ref: main
      path: components
    components: [ ta ]
    refresh: 1d

Configuration

A CAN bus must be available:

canbus:
  - platform: esp32_can
    id: canbus_ta
    can_id: 9
    tx_pin: GPIO13
    rx_pin: GPIO16
    bit_rate: 50kbps
#    mode: LISTENONLY

The mode LISTENONLY is supported as long the ESP device operates only receiving messages from the CAN bus.

Define the TA platform:

ta:
  id: ta_hub
  canbus_id: canbus_ta # this is the reference to the canbus platform
  version: 1 # version of the TA protocol, 1 is the default, can be set to 2
  nodes:
    - node: 1
      ignore_digital: '13-22,28' # digital addresses to be ignored (reduce noise in logs)
      ignore_analog: '5,9-12,27' # analog addresses to be ignored (reduce noise in logs)
    - node: 2
      version: 2 # version of the TA protocol, default is the version of the platform, node-specific overrules always

Sensor configuration (listen onlu)

sensor:
  - platform: ta
    id: node1_analog1
    name: Node 1 Analog 1
    node: 1 # the node on the CAN bus
    address: 1 # the analog address (1..32 for version 1, 1..64 for version 2)
    state_topic: ${mqtt_canbus_topic}/node1/analog1
    accuracy_decimals: 0
    web_server:
      sorting_group_id: webserver_can_node1

binary_sensor:
  - platform: ta
    id: node1_digital1
    name: Node 1 Digital 1
    node: 1 # the node on the CAN bus
    address: 1 # the analog address (1..32)
    state_topic: ${mqtt_canbus_topic}/node1/digital1
    web_server:
      sorting_group_id: webserver_can_node1

Actor configuration

number:
  - platform: ta
    id: node6_analog1
    name: "Node 6 Analog 1"
    node: 6 # the node on the CAN bus
    address: 1 # the analog address (1..32 for version 1, 1..64 for version 2)
    min_value: -200 # optional, defaults to -32768
    max_value: 900 # optional, defaults to 32767
    state_topic: ${mqtt_canbus_topic}/node6/analog1
    command_topic: ${mqtt_canbus_topic}/node6/analog1/command
    web_server:
      sorting_group_id: webserver_can_node6

switch:
  - platform: ta
    id: node6_digital1
    name: "Node 6 Digital 1"
    node: 6  # the node on the CAN bus
    address: 1 # the digital address (1..32)
    state_topic: ${mqtt_canbus_topic}/node6/digital1
    command_topic: ${mqtt_canbus_topic}/node6/digital1/command
    web_server:
      sorting_group_id: webserver_can_node6

Supporting functions

Dumping the log on request is possible:

button:
  - platform: template
    name: "Dump TA Config"
    entity_category: diagnostic
    on_press:
      - lambda: |-
          id(ta_hub).dump_config();
    web_server:
      sorting_group_id: webserver_status

Logging tags follow the common scheme:

logger:
  level: DEBUG
  initial_level: DEBUG
  logs:
    canbus: INFO
    ta: DEBUG
    ta.number: DEBUG
    ta.switch: DEBUG

Building and running

  • Run make init-dev to set up the development environment.
  • Run make build (or just make) to build the component.
  • Run make run to run the component on an ESP device.

Hint regarding compiling errors

For compiling a project with the component, the following options MUST be present in the ESPhome YAML: You don't need to declare any items below the keys, but if they are missing, compiling TA fails.

number:
switch:
sensor:
binary_sensor:

Gerrit Beine, mail@gerritbeine.com

About

ESPhome component for Technische Alternative CAN-bus communication

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages