evcc is a common interface to charge electric vehicles. By default, evcc fetching the required data (meters/sites: grid, PV & battery states) directly from your PV/Battery System. This implies that the load on your PV/Battery system will increase and this could lead unfortunately to internal errors (this just happens to me when I tried to configue evcc via the default SENEC template included in evcc).
We have already all data (evcc needs) in Home Assistant! — so why not use this information and provide it to evcc? The good news is, that this is possible — the bad news is, that' IMHO way to complicate for the average user to configure this.
So I will provide here an example evcc.yml (meters and site section) that can be used in order that evcc will be fed with data from your HA installation (having my SENEC.Home Integration installed).
This tutorial could be used also with other solar integrations — but you need to replace the corresponding sensor entities with the ones that match.
As mentioned in the introduction, with the SENEC.Home integration for HA we have already all home-installation data evcc going to need — we just need a way to provide this HA sensor data to evcc.
Before we can use the HA-API to read sensor data via http, we need some sort of access (for evcc) to the API. Therefor you need to create so-called Long-lived access token. This can be done in the Security tab of your Profile.
You can open this via http://[YOUR-HA-INSTANCE]:8123/profile/security
Create a new token via the Create Token button, specify a name (e.g. 'evcc-access') and then copy the generated token to your clipboard (and paste it to a secure place). A token will look like this:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzNWVjNzg5M2Y0ZjQ0MzBmYjUwOGEwMmU4N2Q0MzFmNyIsImlhdCI6MTcxNTUwNzYxMCwiZXhwIjoyMDMwODY3NjEwfQ.GMWO8saHpawkjNzk-uokxYeaP0GFKPQSeDoP3lCO488
Please do not share your token anywhere! [the token above is really just an example!] — you need to replace all occurrences of [YOUR-TOKEN-HERE] in the following example evcc.yml section with your generated token.
This step is only required, if you want to use alternative HA sensors. In order to support the core features of evcc we need at least current grid power. SENEC.Home.V4 users must use the alternative sensors as they are provided by the 'webapi'. But since this is a SENEC.Home tutorial I will provide here (my) full list of sensors:
-
GRID:
- Power (negative when exporting power to the grid, positive when importing power from the grid)
sensor.senec_grid_state_power
- Current of P1,P2 & P3:
sensor.senec_enfluri_net_current_p1sensor.senec_enfluri_net_current_p2sensor.senec_enfluri_net_current_p3
- Voltage of P1,P2 & P3
sensor.senec_enfluri_net_potential_p1sensor.senec_enfluri_net_potential_p2sensor.senec_enfluri_net_potential_p3
- Power (negative when exporting power to the grid, positive when importing power from the grid)
-
PV:
- Generated power by PV (total):
sensor.senec_solar_generated_power
- Generated power by PV (total):
-
Battery:
- Battery power, negative when consumed by battery (charging) (Please note, that evcc expects a positive value when battery will be charged and a negative when energy from battery will be consumed — we deal with this in the meters configuration later)
sensor.senec_battery_state_power
- State of Charge (in percent)
sensor.senec_battery_charge_percent
- Battery power, negative when consumed by battery (charging) (Please note, that evcc expects a positive value when battery will be charged and a negative when energy from battery will be consumed — we deal with this in the meters configuration later)
There is a new template in evcc allow to specify all (well most of) the required entities in separate blocks. This will reduce the load of your HA and the complexity.
Below you will find a valid evcc meters configuration — but you have to make two replacements:
-
The text '[YOUR-HA-INSTANCE]' has to be replaced with the IP/host name of your Home Assistant installation.
E.g., when your HA is reachable via: http://192.168.10.20:8123, then you need to replace
[YOUR-HA-INSTANCE]with192.168.10.20 -
The text '[YOUR-TOKEN-HERE]' has to be replaced with the Long-lived access token you have just created in HA.
E.g. when your token is:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzNWVjNzg5M2Y0ZjQ0MzBmYjUwOGEwMmU4N2Q0MzFmNyIsImlhdCI6MTcxNTUwNzYxMCwiZXhwIjoyMDMwODY3NjEwfQ.GMWO8saHpawkjNzk-uokxYeaP0GFKPQSeDoP3lCO488, then you need to replace[YOUR-TOKEN-HERE]with this (long) token text.
So as a short example (with all replacements) would look like:
...
type: template
template: homeassistant
usage: grid
uri: http://192.168.10.20:8123
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzNWVjNzg5M2Y0ZjQ0MzBmYjUwOGEwMmU4N2Q0MzFmNyIsImlhdCI6MTcxNTUwNzYxMCwiZXhwIjoyMDMwODY3NjEwfQ.GMWO8saHpawkjNzk-uokxYeaP0GFKPQSeDoP3lCO488
...
meters:
- name: TIBBER.grid
type: template
template: homeassistant
usage: grid
# URI, HTTP(S) address
uri: http://[YOUR-HA-INSTANCE]:8123
# Home Assistant Long-Lived Access Token
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.lan_tibber_0100100700ff
- name: SENEC.grid
type: template
template: homeassistant
usage: grid
# URI, HTTP(S) address
uri: http://[YOUR-HA-INSTANCE]:8123
# Home Assistant Long-Lived Access Token
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.senec_grid_state_power
# L1 Current Entity, Entity ID for L1 current measurement in amperes (optional)
currentL1: sensor.senec_enfluri_net_current_p1
# L2 Current Entity, Entity ID for L2 current measurement in amperes (optional)
currentL2: sensor.senec_enfluri_net_current_p2
# L3 Current Entity, Entity ID for L3 current measurement in amperes (optional)
currentL3: sensor.senec_enfluri_net_current_p3
# L1 Voltage Entity, Entity ID for L1 voltage measurement in volts (optional)
voltageL1: sensor.senec_enfluri_net_potential_p1
# L2 Voltage Entity, Entity ID for L2 voltage measurement in volts (optional)
voltageL2: sensor.senec_enfluri_net_potential_p2
# L3 Voltage Entity, Entity ID for L3 voltage measurement in volts (optional)
voltageL3: sensor.senec_enfluri_net_potential_p3
# Battery State of Charge, Entity ID for battery state of charge in percent (optional)
#soc: sensor.senec_battery_charge_percent
- name: SENEC.pv
type: template
template: homeassistant
usage: pv
uri: http://[YOUR-HA-INSTANCE]:8123
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.senec_solar_generated_power
# Battery State of Charge, Entity ID for battery state of charge in percent (optional)
#soc: sensor.senec_battery_charge_percent
- name: SENEC.bat
type: template
template: homeassistant
usage: battery
uri: http://[YOUR-HA-INSTANCE]:8123
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.senec_battery_state_power
# Battery capacity (kWh), optional
capacity: 12
# Battery State of Charge, Entity ID for battery state of charge in percent (optional)
soc: sensor.senec_battery_charge_percentsee also https://docs.evcc.io/en/docs/devices/meters#home-assistant-meter
meters:
- name: SENEC.grid
type: template
template: homeassistant
usage: grid
# URI, HTTP(S) address
uri: http://[YOUR-HA-INSTANCE]:8123
# Home Assistant Long-Lived Access Token
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.senec_grid_state_power
# Energy Entity, Entity ID for cumulative energy measurement in kWh.
# Should provide total energy consumed/produced, not daily or interval values. (optional)
energy: sensor.house_energy
# L1 Current Entity, Entity ID for L1 current measurement in amperes (optional)
currentL1: sensor.senec_enfluri_net_current_p1
# L2 Current Entity, Entity ID for L2 current measurement in amperes (optional)
currentL2: sensor.senec_enfluri_net_current_p2
# L3 Current Entity, Entity ID for L3 current measurement in amperes (optional)
currentL3: sensor.senec_enfluri_net_current_p3
# L1 Voltage Entity, Entity ID for L1 voltage measurement in volts (optional)
voltageL1: sensor.senec_enfluri_net_potential_p1
# L2 Voltage Entity, Entity ID for L2 voltage measurement in volts (optional)
voltageL2: sensor.senec_enfluri_net_potential_p2
# L3 Voltage Entity, Entity ID for L3 voltage measurement in volts (optional)
voltageL3: sensor.senec_enfluri_net_potential_p3
# Battery State of Charge, Entity ID for battery state of charge in percent (optional)
soc: sensor.senec_battery_charge_percent
- name: SENEC.pv
type: template
template: homeassistant
usage: pv
# URI, HTTP(S) address
uri: http://[YOUR-HA-INSTANCE]:8123
# Home Assistant Long-Lived Access Token
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.senec_solar_generated_power
# Energy Entity, Entity ID for cumulative energy measurement in kWh.
# Should provide total energy consumed/produced, not daily or interval values. (optional)
energy: sensor.house_energy
# L1 Current Entity, Entity ID for L1 current measurement in amperes (optional)
currentL1: sensor.house_current_l1
# L2 Current Entity, Entity ID for L2 current measurement in amperes (optional)
currentL2: sensor.house_current_l2
# L3 Current Entity, Entity ID for L3 current measurement in amperes (optional)
currentL3: sensor.house_current_l3
# L1 Voltage Entity, Entity ID for L1 voltage measurement in volts (optional)
voltageL1: sensor.house_voltage_l1
# L2 Voltage Entity, Entity ID for L2 voltage measurement in volts (optional)
voltageL2: sensor.house_voltage_l2
# L3 Voltage Entity, Entity ID for L3 voltage measurement in volts (optional)
voltageL3: sensor.house_voltage_l3
# Battery State of Charge, Entity ID for battery state of charge in percent (optional)
soc: sensor.senec_battery_charge_percent
# Maximum AC power of the hybrid inverter (W), optional
maxacpower: 0
- name: SENEC.bat
type: template
template: homeassistant
usage: battery
# URI, HTTP(S) address
uri: http://[YOUR-HA-INSTANCE]:8123
# Home Assistant Long-Lived Access Token
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.senec_battery_state_power
# Battery capacity (kWh), optional
capacity: 12
# Battery State of Charge, Entity ID for battery state of charge in percent (optional)
soc: sensor.senec_battery_charge_percent
# Maximum charge power (W), For forced charging of the battery. (optional)
maxchargepower:
# Maximum discharge power (W), Maximum discharge power of the storage. (optional)
maxdischargepower:
# Minimum charge (%), Lower limit when discharging the battery in normal operation (optional)
minsoc: 25
# Maximum charge (%), Upper limit when charging the battery from the grid (optional)
maxsoc: 95
# Energy Entity, Entity ID for cumulative energy measurement in kWh.
# Should provide total energy consumed/produced, not daily or interval values. (optional)
energy: sensor.house_energy
# L1 Current Entity, Entity ID for L1 current measurement in amperes (optional)
currentL1: sensor.house_current_l1
# L2 Current Entity, Entity ID for L2 current measurement in amperes (optional)
currentL2: sensor.house_current_l2
# L3 Current Entity, Entity ID for L3 current measurement in amperes (optional)
currentL3: sensor.house_current_l3
# L1 Voltage Entity, Entity ID for L1 voltage measurement in volts (optional)
voltageL1: sensor.house_voltage_l1
# L2 Voltage Entity, Entity ID for L2 voltage measurement in volts (optional)
voltageL2: sensor.house_voltage_l2
# L3 Voltage Entity, Entity ID for L3 voltage measurement in volts (optional)
voltageL3: sensor.house_voltage_l3
- name: my_aux
type: template
template: homeassistant
usage: aux
# URI, HTTP(S) address
uri: http://[YOUR-HA-INSTANCE]:8123
# Home Assistant Long-Lived Access Token
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.house_power
# Energy Entity, Entity ID for cumulative energy measurement in kWh.
# Should provide total energy consumed/produced, not daily or interval values. (optional)
energy: sensor.house_energy
# L1 Current Entity, Entity ID for L1 current measurement in amperes (optional)
currentL1: sensor.house_current_l1
# L2 Current Entity, Entity ID for L2 current measurement in amperes (optional)
currentL2: sensor.house_current_l2
# L3 Current Entity, Entity ID for L3 current measurement in amperes (optional)
currentL3: sensor.house_current_l3
# L1 Voltage Entity, Entity ID for L1 voltage measurement in volts (optional)
voltageL1: sensor.house_voltage_l1
# L2 Voltage Entity, Entity ID for L2 voltage measurement in volts (optional)
voltageL2: sensor.house_voltage_l2
# L3 Voltage Entity, Entity ID for L3 voltage measurement in volts (optional)
voltageL3: sensor.house_voltage_l3
# Battery State of Charge, Entity ID for battery state of charge in percent (optional)
soc: sensor.senec_battery_charge_percent
- name: my_charger
type: template
template: homeassistant
usage: charge
# URI, HTTP(S) address
uri: http://[YOUR-HA-INSTANCE]:8123
# Home Assistant Long-Lived Access Token
token: [YOUR-TOKEN-HERE]
# Power Entity, Entity ID for instantaneous power measurement in watts.
# The entity must provide numeric values only (e.g., "1234", not "1234 W").
power: sensor.house_power
# Energy Entity, Entity ID for cumulative energy measurement in kWh.
# Should provide total energy consumed/produced, not daily or interval values. (optional)
energy: sensor.house_energy
# L1 Current Entity, Entity ID for L1 current measurement in amperes (optional)
currentL1: sensor.house_current_l1
# L2 Current Entity, Entity ID for L2 current measurement in amperes (optional)
currentL2: sensor.house_current_l2
# L3 Current Entity, Entity ID for L3 current measurement in amperes (optional)
currentL3: sensor.house_current_l3
# L1 Voltage Entity, Entity ID for L1 voltage measurement in volts (optional)
voltageL1: sensor.house_voltage_l1
# L2 Voltage Entity, Entity ID for L2 voltage measurement in volts (optional)
voltageL2: sensor.house_voltage_l2
# L3 Voltage Entity, Entity ID for L3 voltage measurement in volts (optional)
voltageL3: sensor.house_voltage_l3
# Battery State of Charge, Entity ID for battery state of charge in percent (optional)
soc: sensor.senec_battery_charge_percentUse the following meters in your evcc.ymal site configuration (obviously use the aux only if you have similar entries):
site:
...
meters:
grid: SENEC.grid
pv:
- SENEC.pv
battery:
- SENEC.bat
...
- Create a Long-lived access token in HA
- Configure the different evcc meter's (in evcc.yaml) via the
type: customand providepower(¤tsand/orsoc) - Optional: Add additional AUX sources
- Configure your evcc site
- Be happy evcc user without putting extra load on your SENEC.Home!
When you have issues with the http requests to your HA instance, you might like to enable TRACE log level of evcc to find the root cause.
log: trace
