EVCC integration via MQTT (sensor entity config)

You are absolutely right!
I had a look and seems like a lot more data points are nowadays available via MQTT. One could probably add a few of those for meaningful insights. I won’t do that now but everyone who wants to do so, please post them here!
I’ve updated my list above.

Hi all,

I am operating with an Solis Inverter and get data via Modbus (Solax Inverter Modbus) and with waveshare devices on home assistant.

Next step should be EVCC. I am wondering if someone here can help me

  1. to explain me step by step how to use the MQTT Broker in HA and
  2. how to get the data in EVCC (YAML)

thanks for helping.

Best , Philipp

Hey Phil,
this is your first time posting. Because of this, I’ll help you to get what you need.
It is seldom a good idea to ask such open ended questions. Who do you expect will actually help you with step by step instructions?

Did you already set up and connect EVCC to your wallbox? You should start there. Beware that a EVCC addon for HAOS exists, but everything related to its setup can be found in their documentation: https://evcc.io/

After this is done and working, you may continue with MQTT - there are more than enough articles how to install MQTT in HA online, including the official documentation:

Last, configure evcc to publish data to the MQTT broker and check with an mqtt desktop client (like MQTT Explorer).

Finally, if all of this is done and working, you should have aquired the relevant knowledge to take the yaml configuration example from above to include data from evcc in your Home Assistant instance.

Good luck!

Hi @ThomDietrich ,

Thanks for your answer and Support. It was Not really concrete. The mqtt Broker is installed and configured. Evcc (addon) is installed. Yaml file is still to configure. Wallbox is working (windows) .
I am wondering how i can get the data from modbus to the mqtt Broker to config the evcc.yaml. Is there any Support Description?

Thanks for your help

Philipp

You need to practice how to effectively communicate in a forum on the internet. Sorry to say!


Yaml file is still to configure

Which?

Wallbox is working (windows)

What does it have to do with Windows? Windows the operating system??

data from modbus to the mqtt Broker

There shouldn’t be any modbus to mqtt :face_with_peeking_eye: Modbus is probably what you want you want to configure in EVCC. Check the EVCC documentation for how to integrate relevant devices EVCC. EVCC will in the next step publish relevant data, including data received via Modbus, on MQTT.

Is there any Support Description?

For what?

Hi @ThomDietrich , sorry ! You Are Right! I really Need to understand how mqtt works. I do have Data from my inverter in Home Assistant via modbus tcp. I thought to send this Data via mqtt to the evcc(addon) to use the data in here. Anyway, thanks for your Feedback and your help

Hey,
I see. It’s good that you have your inverter data in HA. However, EVCC has support for many inverters, if yours is one of those, you want to integrate it directly

Hi Thom, or anyone concerned :slight_smile:

I tried to implement a second loadpoint by copying the package.yaml and replacing all “loadpoint/1/” to “loadpoint/2/” .

Unfortunately it wasn’t that easy.

Could you give me an hint how to achieve my goal of having both loadpoints available in homeassistant?

Could you be more specific? Sounds like you did not yet check your MQTT broker. That is the beauty of MQTT, you can use any MQTT client to see which information is exchanged. Use MQTT Explorer or any other software to see which data is published by EVCC and which or if any datapoints are published under loadpoint/2/. That should help you to resolve your issue.

Hi there, i hope your are good.
thanks to this thread i was able to create the buttons in HA to manage the status if EVCC.
Works fine so far.
The only issue i have is, that either all button are on or off.
So all icons went to the off status if the status is off, otherwise al status are on, which is correct per se, but i would like to have only the current status shown as on.

How could i manage this ?

here is the yaml

square: false
columns: 1
type: grid
cards:
  - type: custom:mushroom-title-card
    title: Schnellaufgaben
    alignment: center
  - type: custom:mushroom-entity-card
    entity: climate.gunther_hvac_climate_system
    layout: horizontal
    fill_container: false
    secondary_info: none
    icon: mdi:car-wireless
    hold_action:
      action: none
    double_tap_action:
      action: none
    tap_action:
      action: toggle
    name: 'Günther - Klima '
  - square: false
    type: grid
    cards:
      - type: custom:mushroom-entity-card
        entity: select.evcc_mode
        name: Stoppen
        tap_action:
          action: call-service
          service: select.select_option
          service_data:
            entity_id: select.evcc_mode
            option: 'off'
        icon: mdi:power
        hold_action:
          action: none
        fill_container: false
        layout: vertical
        double_tap_action:
          action: none
        secondary_info: none
        primary_info: name
      - type: custom:mushroom-entity-card
        entity: select.evcc_mode
        name: PV
        tap_action:
          action: call-service
          service: select.select_option
          service_data:
            entity_id: select.evcc_mode
            option: pv
        icon: mdi:power
        hold_action:
          action: none
        layout: vertical
        fill_container: false
        primary_info: name
        secondary_info: none
      - type: custom:mushroom-entity-card
        entity: select.evcc_mode
        name: PV +
        tap_action:
          action: call-service
          service: select.select_option
          service_data:
            entity_id: select.evcc_mode
            option: minpv
        icon: mdi:power
        hold_action:
          action: none
        layout: vertical
        fill_container: false
        primary_info: name
        secondary_info: none
      - type: custom:mushroom-entity-card
        entity: select.evcc_mode
        name: Voll
        tap_action:
          action: call-service
          service: select.select_option
          service_data:
            entity_id: select.evcc_mode
            option: now
        icon: mdi:power
        hold_action:
          action: none
        layout: vertical
        fill_container: false
        primary_info: name
        secondary_info: none
        double_tap_action:
          action: none
    columns: 4

Hi, thanks for providing this config, really like having those sensors in HA.
Im looking to get the EVCC charging plan into HA so i can automate on that (if car x is connected automaticly set charging plan for next morning)
Has anyone managed this already?

I will try to be more specific.

I have done as you described in your post from 25th February: EVCC integration via MQTT (sensor entity config) - #19 by ThomDietrich

I have created the evcc.yaml file in packages and enabled packages in the configuration.yaml.
I have copied the evcc.yaml to a second one (evcc2.yaml) and replaced all references to loadpoint1 with loadpoint 2.

Unfortunately it would only show the sensors of loadpoints 1, but not loadpoints 2 in homeassistant.

When exploring the topics in mqtt explorer it would show both loadpoints, so they are published well.

Did I miss something else to be replaced in the evcc2.yaml file maybe?

Now it’s clear.

Each sensor needs a unique unique_id.
Example:

sensor:
    - name: evcc_loadpoint1_charge_power_w
      unique_id: uniqueid__evcc_loadpoint1_charge_power_w
      icon: mdi:car-electric
      state_topic: "evcc/loadpoints/1/chargePower"
      ...
    - name: evcc_loadpoint2_charge_power_w
      unique_id: uniqueid__evcc_loadpoint2_charge_power_w
      icon: mdi:car-electric
      state_topic: "evcc/loadpoints/2/chargePower"
      ...
1 Like

First: Can you share your card-config?
Your’s much smaller than mine.

Secondly: Is it true, that you can’t pull the SoC of a Car?
I ditn’t find anything like that in the EVCC API

type: vertical-stack
cards:
  - type: custom:button-card
    color_type: label-card
    color: rgb(3, 169, 244)
    name: Ladestationen
    styles:
      name:
        - font-weight: bold
        - color: white
  - type: vertical-stack
    cards:
      - type: horizontal-stack
        cards:
          - type: custom:button-card
            entity: select.evcc_mode_lp1
            show_name: false
            color: rgb(3, 169, 244)
            show_state: true
            state:
              - value: 'off'
                styles:
                  icon:
                    - color: grey
              - value: now
                styles:
                  icon:
                    - color: red
              - value: minpv
                styles:
                  icon:
                    - color: lightgreen
              - value: pv
                styles:
                  icon:
                    - color: green
          - type: custom:button-card
            entity: select.evcc_mode_lp2
            show_name: false
            color: rgb(3, 169, 244)
            show_state: true
            state:
              - value: 'off'
                styles:
                  icon:
                    - color: grey
              - value: now
                styles:
                  icon:
                    - color: red
              - value: minpv
                styles:
                  icon:
                    - color: lightgreen
              - value: pv
                styles:
                  icon:
                    - color: green
      - type: horizontal-stack
        cards:
          - type: custom:button-card
            entity: sensor.evcc_charged_energy_kwh_lp1
            color: rgb(3, 169, 244)
            show_state: true
            show_name: false
            state_color: false
          - type: custom:button-card
            entity: sensor.evcc_charged_energy_kwh_lp2
            color: rgb(3, 169, 244)
            show_state: true
            show_name: false
            state_color: false
      - type: horizontal-stack
        cards:
          - type: custom:button-card
            entity: binary_sensor.evcc_loadpoint_connected_lp1
            color: rgb(3, 169, 244)
            icon: null
            show_state: true
            show_name: false
            state:
              - value: 'off'
                styles:
                  icon:
                    - color: grey
              - value: 'on'
                styles:
                  icon:
                    - color: rgb(255, 193, 7)
          - type: custom:button-card
            entity: binary_sensor.evcc_loadpoint_connected_lp2
            color: rgb(3, 169, 244)
            show_state: true
            show_name: false
            state:
              - value: 'off'
                styles:
                  icon:
                    - color: grey
              - value: 'on'
                styles:
                  icon:
                    - color: rgb(255, 193, 7)
      - type: horizontal-stack
        cards:
          - type: gauge
            entity: sensor.evcc_charge_power_w_lp1
            name: Garage
            needle: true
            min: 0
            max: 22000
            severity:
              green: 0
              yellow: 14000
              red: 18000
          - type: gauge
            entity: sensor.evcc_charge_power_w_lp2
            name: Fahrradgarage
            needle: true
            min: 0
            max: 22000
            severity:
              green: 0
              yellow: 14000
              red: 18000

have the same question!

The code must go in a file under <HomeAssistantConfig>/packages/evcc-or-similar-name.yaml. In order to load that file you need to also enable packages in your <HomeAssistantConfig>/configuration.yaml. Read:

Perhaps it helps anyone.
My mqtt.yaml for two load points.

mqtt:
  select:
    - name: evcc_mode_LP1
      unique_id: uniqueid__evcc_mode_LP1_select
      icon: mdi:tune-variant
      state_topic: "evcc/loadpoints/1/mode"
      command_topic: "evcc/loadpoints/1/mode/set"
      availability_topic: "evcc/status"
      value_template: >
          {% if value == 'off' %}
            Aus
          {% elif value == 'pv' %}
            PV
          {% elif value == 'minpv' %}
            Minimum + PV
          {% else %}
            Schnell
          {% endif %}
      command_template: >
          {% if value == 'Aus' %}
            off
          {% elif value == 'PV' %}
            pv
          {% elif value == 'Minimum + PV' %}
            minpv
          {% else %}
            now
          {% endif %}
      options:
        - "Aus"
        - "PV"
        - "Minimum + PV"
        - "Schnell"

    - name: evcc_mode_LP2
      unique_id: uniqueid__evcc_mode_LP2_select
      icon: mdi:tune-variant
      state_topic: "evcc/loadpoints/2/mode"
      command_topic: "evcc/loadpoints/2/mode/set"
      availability_topic: "evcc/status"
      value_template: >
          {% if value == 'off' %}
            Aus
          {% elif value == 'pv' %}
            PV
          {% elif value == 'minpv' %}
            Minimum + PV
          {% else %}
            Schnell
          {% endif %}
      command_template: >
          {% if value == 'Aus' %}
            off
          {% elif value == 'PV' %}
            pv
          {% elif value == 'Minimum + PV' %}
            minpv
          {% else %}
            now
          {% endif %}
      options:
        - "Aus"
        - "PV"
        - "Minimum + PV"
        - "Schnell"

  #############################################################################

  sensor:
    - name: evcc_charge_power_w_LP1
      unique_id: uniqueid__LP1_evcc_charge_power_w
      icon: mdi:car-electric
      state_topic: "evcc/loadpoints/1/chargePower"
      value_template: "{{ value | round(0) }}"
      unit_of_measurement: "W"
      state_class: measurement
      availability_topic: "evcc/status"

    - name: evcc_charge_power_w_LP2
      unique_id: uniqueid__LP2_evcc_charge_power_w
      icon: mdi:car-electric
      state_topic: "evcc/loadpoints/2/chargePower"
      value_template: "{{ value | round(0) }}"
      unit_of_measurement: "W"
      state_class: measurement
      availability_topic: "evcc/status"

    - name: evcc_charged_energy_kwh_LP1
      unique_id: uniqueid__evcc_charged_energy_kwh_LP1
      icon: mdi:battery-charging-high
      state_topic: "evcc/loadpoints/1/chargedEnergy"
      value_template: "{{ (value | float / 1000) | round(4) }}"
      unit_of_measurement: "kWh"
      availability_topic: "evcc/status"

    - name: evcc_charged_energy_kwh_LP2
      unique_id: uniqueid__evcc_charged_energy_kwh_LP2
      icon: mdi:battery-charging-high
      state_topic: "evcc/loadpoints/2/chargedEnergy"
      value_template: "{{ (value | float / 1000) | round(4) }}"
      unit_of_measurement: "kWh"
      availability_topic: "evcc/status"

    #############################################################################

    - name: evcc_charge_duration_s_LP1
      unique_id: uniqueid__evcc_charge_duration_s_LP1
      icon: mdi:timer-settings-outline
      state_topic: "evcc/loadpoints/1/chargeDuration"
      value_template: "{{ value | round(0) }}"
      unit_of_measurement: "s"
      availability_topic: "evcc/status"

    - name: evcc_charge_duration_s_LP2
      unique_id: uniqueid__evcc_charge_duration_s_LP2
      icon: mdi:timer-settings-outline
      state_topic: "evcc/loadpoints/2/chargeDuration"
      value_template: "{{ value | round(0) }}"
      unit_of_measurement: "s"
      availability_topic: "evcc/status"

    #############################################################################

    - name: evcc_charge_current_l1_a_LP1
      unique_id: uniqueid__evcc_charge_current_l1_a_LP1
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/1/chargeCurrents/l1"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "A"
      availability_topic: "evcc/status"

    - name: evcc_charge_current_l2_a_LP1
      unique_id: uniqueid__evcc_charge_current_l2_a_LP1
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/1/chargeCurrents/l2"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "A"
      availability_topic: "evcc/status"

    - name: evcc_charge_current_l3_a_LP1
      unique_id: uniqueid__evcc_charge_current_l3_a_LP1
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/1/chargeCurrents/l3"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "A"
      availability_topic: "evcc/status"


    - name: evcc_charge_current_l1_a_LP2
      unique_id: uniqueid__evcc_charge_current_l1_a_LP2
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/2/chargeCurrents/l1"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "A"
      availability_topic: "evcc/status"

    - name: evcc_charge_current_l2_a_LP2
      unique_id: uniqueid__evcc_charge_current_l2_a_LP2
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/2/chargeCurrents/l2"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "A"
      availability_topic: "evcc/status"

    - name: evcc_charge_current_l3_a_LP2
      unique_id: uniqueid__evcc_charge_current_l3_a_LP2
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/2/chargeCurrents/l3"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "A"
      availability_topic: "evcc/status"
    #############################################################################

    #############################################################################

    #############################################################################

  binary_sensor:
    - name: evcc_loadpoint_enabled_LP1
      unique_id: uniqueid__evcc_loadpoint_enabled_LP1
      icon: mdi:ev-station
      state_topic: "evcc/loadpoints/1/enabled"
      payload_on: "true"
      payload_off: "false"
      #device_class: problem
      availability_topic: "evcc/status"

    - name: evcc_loadpoint_connected_LP1
      unique_id: uniqueid__evcc_loadpoint_connected_LP1
      icon: mdi:ev-station
      state_topic: "evcc/loadpoints/1/connected"
      payload_on: "true"
      payload_off: "false"
      #device_class: problem
      availability_topic: "evcc/status"

    - name: evcc_loadpoint_charging_LP1
      unique_id: uniqueid__evcc_loadpoint_charging_LP1
      icon: mdi:ev-station
      state_topic: "evcc/loadpoints/1/charging"
      payload_on: "true"
      payload_off: "false"
      #device_class: problem
      availability_topic: "evcc/status"


    - name: evcc_loadpoint_enabled_LP2
      unique_id: uniqueid__evcc_loadpoint_enabled_LP2
      icon: mdi:ev-station
      state_topic: "evcc/loadpoints/2/enabled"
      payload_on: "true"
      payload_off: "false"
      #device_class: problem
      availability_topic: "evcc/status"

    - name: evcc_loadpoint_connected_LP2
      unique_id: uniqueid__evcc_loadpoint_connected_LP2
      icon: mdi:ev-station
      state_topic: "evcc/loadpoints/2/connected"
      payload_on: "true"
      payload_off: "false"
      #device_class: problem
      availability_topic: "evcc/status"

    - name: evcc_loadpoint_charging_LP2
      unique_id: uniqueid__evcc_loadpoint_charging_LP2
      icon: mdi:ev-station
      state_topic: "evcc/loadpoints/2/charging"
      payload_on: "true"
      payload_off: "false"
      #device_class: problem
      availability_topic: "evcc/status"

  #############################################################################

  number:
    - name: evcc_min_current_LP1
      unique_id: uniqueid__evcc_min_current_LP1
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/1/minCurrent"
      command_topic: "evcc/loadpoints/1/minCurrent/set"
      availability_topic: "evcc/status"
      min: 6
      max: 32
      step: 0.25
      unit_of_measurement: "A"

    - name: evcc_max_current_LP1
      unique_id: uniqueid__evcc_max_current_LP1
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/1/maxCurrent"
      command_topic: "evcc/loadpoints/1/maxCurrent/set"
      availability_topic: "evcc/status"
      min: 6
      max: 32
      step: 0.25
      unit_of_measurement: "A"

    - name: evcc_min_current_LP2
      unique_id: uniqueid__evcc_min_current_LP2
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/2/minCurrent"
      command_topic: "evcc/loadpoints/2/minCurrent/set"
      availability_topic: "evcc/status"
      min: 6
      max: 32
      step: 0.25
      unit_of_measurement: "A"

    - name: evcc_max_current_LP2
      unique_id: uniqueid__evcc_max_current_LP2
      icon: mdi:current-ac
      state_topic: "evcc/loadpoints/2/maxCurrent"
      command_topic: "evcc/loadpoints/2/maxCurrent/set"
      availability_topic: "evcc/status"
      min: 6
      max: 32
      step: 0.25
      unit_of_measurement: "A"
#############################################################################
homeassistant:
  customize:
    number.evcc_min_currentL_P1:
      friendly_name: "Garage Wallbox Minimale Stromstärke"
    select.evcc_mode_P1:
      friendly_name: "Garage EVCC Modus"
    number.evcc_min_currentL_P2:
      friendly_name: "Fahrradbox Wallbox Minimale Stromstärke"
    select.evcc_mode_P2:
      friendly_name: "Fahrradbox EVCC Modus"

My evcc.yaml

network:
  schema: http
  host: evcc.local # .local suffix announces the hostname on MDNS
  port: 7070

log: info
levels:
    cache: error

interval: 5s
    
site:
    title: Home
    meters:
        grid: EVU
        pv:
        - PV1
        - PV2
        battery:
        - Batterie
    residualPower: 200 # Positiver Wert: Verbleibende Netzeinspeiseleistung
    #prioritySoc: 30 # Hausbatterie bekommt bis zum Soc 30% Priorität beim laden

meters:
-   name: PV1
    type: template
    template: fronius-gen24
    usage: pv
    host: 192.168.5.10
    port: 502

-   name: PV2
    type: template
    template: fronius-gen24
    usage: pv
    host: 192.168.5.12
    port: 502

-   name: EVU
    type: template
    template: fronius-gen24
    host: 192.168.5.10
    port: 502
    usage: grid

-   name: Batterie
    type: template
    template: fronius-gen24
    host: 192.168.5.10
    port: 502
    usage: battery

-   name: LP1
    type: template
    template: eastron-sdm72
    usage: charge
    modbus: rs485tcpip
    id: 105
    host: 192.168.5.141
    port: 502

-   name: LP2
    type: template
    template: eastron
    usage: charge
    modbus: rs485tcpip
    id: 106
    host: 192.168.5.141
    port: 502

chargers:
-   name: evse-1
    type: template
    template: evse-din
    modbus: rs485tcpip
    id: 1
    host: 192.168.5.141
    port: 502

-   name: evse-2
    type: template
    template: evse-din
    modbus: rs485tcpip
    id: 2
    host: 192.168.5.141
    port: 502

vehicles:
-   name: Ecto-1
    type: template
    template: ford
    title: Mustang
    user: xxx
    password: xxx
    capacity: 98
    mode: now
    minCurrent: 6
    maxCurrent: 32
    identifiers:
        - xxx

-   name: Zoe
    type: template
    template: renault
    title: Zoe
    user: xxx
    password: xxx
    capacity: 51
    mode: now
    cloud: false
    minCurrent: 8
    maxCurrent: 32
    identifiers:
        - xxx

loadpoints:
-   title: Garage
    charger: evse-1
    mode: off
    meter: LP1
    phases: 3
#    mincurrent: 6
    maxcurrent: 32
    guardduration: 10s
    enable:
        delay: 1m
        threshold: -4200 # es wird eingeschaltet, wenn 1 Minute lang 4200 W Einspeisung vorhanden sind
    disable:
        delay: 2m
        threshold: 1200 # es wird ausgeschaltet, wenn 2 Minuten lang mehr als 1200 W Netzstrom bezogen wurde

-   title: Fahrradgarage
    charger: evse-2
    mode: off
    meter: LP2
    phases: 3
#    mincurrent: 6
    maxcurrent: 32
    guardduration: 10s
#    vehicle: Ecto-1
    enable:
        delay: 1m
        threshold: -4200 # es wird eingeschaltet, wenn 1 Minute lang 4200 W Einspeisung vorhanden sind
    disable:
        delay: 2m
        threshold: 1200 # es wird ausgeschaltet, wenn 2 Minuten lang mehr als 1200 W Netzstrom bezogen wurde

tariffs:
    currency: EUR # (default EUR)
    grid:
        type: fixed
        price: 0.2695 # [currency]/kWh

    feedin:
        type: fixed
        price: 0.1873 # [currency]/kWh

# mqtt message broker
mqtt:
    broker: localhost:1883
    topic: evcc # root topic for publishing, set empty to disable publishing
    clientid: EVCC
    user: evcc
    password: xxx

Hi, i want also switch from HA the phases in evcc, like the mode (aus, pv, pvmin, schnell).

image

The name of the Entity from your example is [select.evcc_phases]. When i set here an other value, i see it in the mqtt explorer under set, but nothing change in evcc.

Example phase was set with 1 and i want to change it from ha to 3.
image

Is this not possible or did they changed within evcc something ?

Hey!
Over the last two years the guys over in evcc have changed quite a few things. It was a bit messy at times but it feels like things have settled. I should update my configuration, also with all the provided improvements by others in this thread here.

Anyhow, have a look here: API | evcc - Sonne tanken ☀️🚘 → I think you want to switch to this topic: evcc/loadpoints/1/phases/set

Hi, yes thx for the info. Found this side in the same moment. I will open a ticket directly in the evcc forum.