EVCC integration via MQTT (sensor entity config)

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.

Found in the documentation for the phase switch the hint. The sensor must be set like:

  - name: evcc_phases
    unique_id: uniqueid__evcc_phases_select
    icon: mdi:backburger
    state_topic: "evcc/loadpoints/1/phasesEnabled"
    command_topic: "evcc/loadpoints/1/phases/set"
    availability_topic: "evcc/status"
    options:
      - "1"
      - "3"

Now it is possible to switch between 1 phase and 3 phase for my NRGKick Charger, because the charger is not directly implemented in evcc and i have to control it with mqtt as an universal charger. With this switch i change the setting within the evcc and also on the charger.

image
image
image

one click on the button →
image
image
image

Thx for your support :wink:

Hey all,
thanks for the ton of useful sensors. I wanted to get rid of my FiatChamp addon, since its doublicating queries against the FIAT API, so I checked and EVCC nicely had all the values I was looking for.
So I also added the following entities:

  sensor:
    - name: evcc_charge_duration_time
      unique_id: uniqueid__evcc_charge_duration_time
      icon: mdi:timer-settings-outline
      state_topic: "evcc/loadpoints/1/chargeDuration"
      value_template: "{{ value | int(0) | timestamp_custom('%-Hh %-Mmin %-Ssec', false) }}"
      availability_topic: "evcc/status"

    - name: evcc_vehicle_soc
      unique_id: uniqueid__evcc_vehicle_soc
      icon: mdi:fuel-cell
      state_topic: "evcc/loadpoints/1/vehicleSoc"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "%"
      availability_topic: "evcc/status"

    - name: evcc_vehicle_range
      unique_id: uniqueid__evcc_vehicle_range
      icon: mdi:map-marker-distance
      state_topic: "evcc/loadpoints/1/vehicleRange"
      value_template: "{{ value | round(0) }}"
      unit_of_measurement: "km"
      availability_topic: "evcc/status"

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

    - name: evcc_session_solar_percent
      unique_id: uniqueid__evcc_session_solar_percent
      icon: mdi:weather-sunny-alert
      state_topic: "evcc/loadpoints/1/sessionSolarPercentage"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "%"
      availability_topic: "evcc/status"

Perhaps someone might find them useful.
Best

1 Like

Many thanks for the code here.

A short question, because that just took me some time to fix:

“evcc/status” is not an entity in my installation. I couldn’t control mode without deleting that line.

Is there any harm in not having an availability_topic ?

Hey there, happy you found this useful.
Seems something weird is going on here.

“evcc/status” is not an entity in my installation.

Your EVCC instance should publish the evcc/status topic. Please use an MQTT client (http://mqtt-explorer.com/) and check which messages are on the broker. You might want to restart EVCC to trigger a complete set of published messages.

Is there any harm in not having an availability_topic ?

Not in the first step. However, availability is an important concept in Home Assistant. If your EVCC instance is stopped, you will be left with entities holding the last known value published by EVCC. Your HomeAssistant setup will have you believe false/outdated information (Car still at 30% battery charge after a full day of charging). This could also lead to malfunctioning automations etc.
In order to avoid this and to aid in troubleshooting, it’s important to mark an entity as unavailable. This is where the availability_topic is necessary.

Hi @ThomDietrich

Vielen Dank für Deine Konfiguration. Wir haben uns erlaubt auf Basis Deiner Konfiguration in unserem GitHub repository entsprechende YAMLs anzulegen und zu teilen: homeassistant-puzzlepieces/installation/evcc-mqtt-integration at main · ha-puzzles/homeassistant-puzzlepieces · GitHub. Und zwar modular, so dass man diese pro Vehicle und Loadpoint einfacher auswählen kann.

Zudem ändern sich die Topics ja ständig.

Da nun auch einige Werte vom Loadpoint zum Vehicle gewandert sind, haben wir außerdem noch Automations und Helfer erzeugt.

Ich hoffe das ist für Dich so in Ordnung.

Viele Grüße,
Carsten

1 Like

Hallo Carsten, das ist absolut in Ordnung! Im Gegenteil, ich finde den Mehrwert den ich auf Anhieb sehe super.
Ich vermute ihr habt euch bewusst dazu entschieden auf Deutsch zu dokumentieren. Das ist gut und fein aber bedeutet leider, dass wir eure Arbeit hier nicht pauschal für die breite Community anbieten können…

Übrigens, ich dachte mir immer mal wieder, dass statt einer verbesserten Liste an yaml entities eine HA integration/component für EVCC stark wäre. Die Implementierung kann nicht so kompliziert sein, im wesentlichen müssen abhängig von ge-publish-ten Daten Entities generiert werden…

2 Likes

Hi everyone,

it seems my home assistant config is not capable of receiving any evcc mqtt messages.

State:

  1. Home assistant MQTT is running and working with other devices (DTUs from inverters). MQTT account is set up.
  2. EVCC is running and publishing MQTT, IP/Port/User/Password of mqtt home assistant is properly written in the evcc.yaml. I can see the messages via MQTT explorer. There are 0 error messages in the log of EVCC on the debug level.
  3. There is no way to make the mqtt integration of home assistant read the evcc messages. Listening on topic will also not produce anything. Restart of home assistant has not worked. There is nothing in the logs of MQTT (even though debug protocol is activated).

What am I missing?

Hi everyone,
there is another new value available: bufferStartSoc names the battery level, when pv mode charging starts even w/o enough live solar power. It can be configured identically to buffersoc.
cu, H
image

is it possible to show the pv powers in details. I have 3 pv’s in evcc and i want to show the individually sources, not only the total PV power

add “0” to options if you have automated switching, 0 stands for auto, you need extra lines in evcc.yaml for your charger

Phases1p3p: # phase switching (1/3)
  source: mqtt
  topic: *your topic*
tos: true

This gets charge planner times, start and finish.

sensor:
    - name: evcc_plan_start_time_lp1
      unique_id: uniqueid__evcc_plan_start_time_lp1
      icon: mdi:timer-settings-outline
      state_topic: "evcc/loadpoints/1/planProjectedStart"
      value_template: "{{ value | int(0) | timestamp_custom('%H:%M %d/%m/%y', local=true) }}"
      availability_topic: "evcc/status"
      
    - name: evcc_plan_finish_time_lp1
      unique_id: uniqueid__evcc_plan_finish_time_lp1
      icon: mdi:timer-settings-outline
      state_topic: "evcc/loadpoints/1/effectivePlanTime"
      value_template: "{{ value | int(0) | timestamp_custom('%H:%M %d/%m/%y', local=true) }}"
      availability_topic: "evcc/status"

Can anyone help with getting time and date on seperate lines, like this

12:00
15/05/24

there is now a custom component for evcc
has a lot more capabilites

3 Likes

Finally! I was thinking of creating one more than once but never got around to it.
Thanks to the author for this :slight_smile:

2 Likes

Anyone know how to delete/disable charge plan with MQTT message??
That integration seems to have it…

Send a charge plan for some day in the future with 0 kWh of energy.