Skip to content
Martin edited this page Oct 1, 2021 · 1 revision

Heidelberg Wallbox configuration

external_components:
  - source:
      type: git
      url: https://github.com/esphome/esphome
      ref: dev
    components: [ modbus, modbus_controller ]
      
substitutions:
  devicename: heidelberg_wb_example
  
esphome:
  name: $devicename
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: !secret wifi_sid
  password: !secret wifi_password
  use_address: heidelberg_wb_example
  fast_connect: true

# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${devicename} Fallback Hotspot"
    password: !secret wifi_password
    
# Enable Home Assistant API
api:
  reboot_timeout: 60min #Reboot when no connection

captive_portal:

# Enable logging
logger:
  level: INFO

ota:

uart:
  id: mod_bus
  tx_pin: 5
  rx_pin: 2
  baud_rate: 19200
  stop_bits: 1
  parity: even

modbus:
  id: modbus_heidelberg_wallbox
  flow_control_pin: 4
  send_wait_time: 200ms
  
modbus_controller:
  - id: heidelberg_wallbox_id01
    address: 0x1
    modbus_id: modbus_heidelberg_wallbox
    command_throttle: 200ms
    setup_priority: -10
    update_interval: 60s

sensor:
  - platform: wifi_signal
    name: "WiFi Signal ${devicename}"
    update_interval: 300s
    
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: version
    name: "Version"
    address: 0x0004
    register_type: read
    value_type: U_WORD
    
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: charg_state
    name: "charging state"
    address: 0x0005
    register_type: read
    value_type: U_WORD
    
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: l1_a_rms
    name: "L1 A rms"
    address: 0x0006
    unit_of_measurement: "A rms"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
     
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: l2_a_rms
    name: "L2 A rms"
    address: 0x0007
    unit_of_measurement: "A rms"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: l3_a_rms
    name: "L3 A rms"
    address: 0x0008
    unit_of_measurement: "A rms"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: pcb_temp
    name: "PCB-Temperatur"
    address: 0x0009
    unit_of_measurement: "°C"
    register_type: read
    value_type: S_WORD
    skip_updates: 300
    accuracy_decimals: 1
    filters:
      - multiply: 0.1
      
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: l1_v_rms
    name: "L1 V rms"
    address: 0x000A
    unit_of_measurement: "V rms"
    register_type: read
    value_type: U_WORD
    skip_updates: 60
    accuracy_decimals: 0

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: l2_v_rms
    name: "L2 V rms"
    address: 0x000B
    unit_of_measurement: "V rms"
    register_type: read
    value_type: U_WORD
    skip_updates: 60
    accuracy_decimals: 0
 
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: l3_v_rms
    name: "L3 V rms"
    address: 0x000C
    unit_of_measurement: "V rms"
    register_type: read
    value_type: U_WORD
    skip_updates: 60
    accuracy_decimals: 0
 
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: extern_lock_state
    name: "extern lock state"
    address: 0x000D
    register_type: read
    value_type: U_WORD
    
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: l1_l2_l3_power
    name: "L1 L2 L3 Power"
    address: 0x000E
    unit_of_measurement: "kW"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 2
    filters:
      - multiply: 0.001
      
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: kwh_power_on
    name: "KWH Power On"
    address: 0x000F
    unit_of_measurement: "kWh"
    register_type: read
    value_type: U_DWORD
    accuracy_decimals: 3
    filters:
      - multiply: 0.001
      
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: kwh_total
    name: "KWH Total"
    address: 0x0011
    unit_of_measurement: "kWh"
    register_type: read
    value_type: U_DWORD
    accuracy_decimals: 3
    filters:
      - multiply: 0.001

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: fix_max_current
    name: "fix max current"
    address: 0x0064
    unit_of_measurement: "A"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 0

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: fix_min_current
    name: "fix min current"
    address: 0x0065
    unit_of_measurement: "A"
    register_type: read
    value_type: U_WORD
    accuracy_decimals: 0
 
  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: watchdog
    name: "watchdog"
    address: 0x0101
    unit_of_measurement: "ms"
    register_type: holding
    value_type: U_WORD
    skip_updates: 0

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: stand_by_control
    name: "stand by control"
    address: 0x0102
    register_type: holding
    value_type: U_WORD
    skip_updates: 0

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: remote_lock
    name: "remote_lock"
    address: 0x0103
    register_type: holding
    value_type: U_WORD
    skip_updates: 0

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: max_current
    name: "max current"
    address: 0x0105
    unit_of_measurement: "A"
    register_type: holding
    value_type: U_WORD
    skip_updates: 0
    accuracy_decimals: 0
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: heidelberg_wallbox_id01  
    id: failsafe_current
    name: "failsafe current"
    address: 0x0106
    unit_of_measurement: "A"
    register_type: holding
    value_type: U_WORD
    skip_updates: 0
    accuracy_decimals: 0
    filters:
      - multiply: 0.1

  - platform: homeassistant
    entity_id: input_number.wb_max_current #Slider from HASS, create as Helper
    id: wb_max_current
    internal: true
    on_value:
      then:
        - lambda: |-
            uint16_t payload = id(wb_max_current).state * 10;
            ESP_LOGI("main", "set max current %d", payload);
            // Create a modbus command item with the max current value as the payload
            esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(heidelberg_wallbox_id01, 0x0105, payload);
            // Submit the command to the send queue
            heidelberg_wallbox_id01->queue_command(set_payload_command);

  - platform: homeassistant
    entity_id: input_number.wb_watchdog_timeout
    id: wb_watchdog_timeout
    internal: true
    on_value:
      then:
        - lambda: |-
            uint16_t payload = id(wb_watchdog_timeout).state;
            ESP_LOGI("main", "set watchdog_timeout %d", payload);
            esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(heidelberg_wallbox_id01, 0x0101, payload);
            heidelberg_wallbox_id01->queue_command(set_payload_command);

  - platform: homeassistant
    entity_id: input_number.wb_max_failsafe_current
    id: wb_max_failssafe_current
    internal: true
    on_value:
      then:
        - lambda: |-
            uint16_t payload = id(wb_max_failssafe_current).state * 10;
            ESP_LOGI("main", "set max failssafe current %d", payload);
            esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(heidelberg_wallbox_id01, 0x0106, payload);
            heidelberg_wallbox_id01->queue_command(set_payload_command);

binary_sensor:
  - platform: homeassistant
    entity_id: input_boolean.wb_remote_lock
    id: wb_remote_lock
    internal: true
    on_state:
      then:
        - lambda: |-
            uint16_t payload = 1;
            if ( id(wb_remote_lock).state == true ) {
              payload = 0;
            }
            ESP_LOGI("main", "set remote lock %d", payload);
            esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(heidelberg_wallbox_id01, 0x0103, payload);
            heidelberg_wallbox_id01->queue_command(set_payload_command);

  - platform: homeassistant
    entity_id: input_boolean.wb_standby_control
    id: wb_standby_control
    internal: true
    on_state:
      then:
        - lambda: |-
            uint16_t payload = 4;
            if ( id(wb_standby_control).state == true ) {
              payload = 0;
            }
            ESP_LOGI("main", "set standby control %d", payload);
            esphome::modbus_controller::ModbusCommandItem set_payload_command = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(heidelberg_wallbox_id01, 0x0102, payload);
            heidelberg_wallbox_id01->queue_command(set_payload_command);
Clone this wiki locally