Charge green power with wallbox go-eCharger (API V2) in Germany

My idea was to charge my electric car at home from go-eCharger wallbox mostly with “green power”.
For that I found the site https://gruenstromindex.de/, where you can read the “green power index” of german areas with your zip code. It shows a matrix with times and values, where the level of produced energy mostly by water, sun or wind in your area is shown by green color and the highest percentage level.
So if you charge your car at the time with the highest level, you charge power produced by renewable energies, which is most ecologic.
These values can be read by API with the url https://corrently.de/api/stromdao/gsi?zip=10115.
Response is sent back in JSON.


You can integrate these values in HASS by calling two rest calls, one that reads the go-e data and one that reads stromado data:

# go-echarger v2
- platform: rest
  resource: !secret goecharger_api_url
  scan_interval: 20
  name: "go-eCharger v2"
  value_template: "{{ value_json['car'] }}"
  json_attributes:
    - att
# stromado green index data
- platform: rest
  resource: "https://corrently.de/api/stromdao/gsi?zip=10115"
  name: "Stromado Green Index Data"
  value_template: "OK"
  json_attributes:
    - forecast

These values can be set to the lovelace components.

2022-01-06 11_58_28-Window

I’m using a custom:time-picker-card to show the given charging end-time from go-eCharger and a custom:paper-buttons-row to show the green index time with the highest “green index level”, which you get by the following templates:

# go-echarger autostop time - from 00:00 in seconds (raw)
goecharger_autostop_time_setting:
  friendly_name: "go-e Autostop Zeit Einstellung"
  icon_template: mdi:clock
  value_template: "{{ state_attr('sensor.go_echarger_v2', 'att') | timestamp_custom('%H:%M', 0) }}"
# go-echarger green index charging end time by stromado
goecharger_green_index_charging_time:
  friendly_name: "go-e Grünindex Lade-Endzeit"
  icon_template: mdi:content-save-move
  value_template: >
	{% set forecast = state_attr('sensor.stromado_green_index_data', 'forecast') %}
	{% set maxLevel = forecast | map(attribute='eevalue') | max %}
	{% set entity = forecast | selectattr('eevalue', 'eq', maxLevel) | list | first %}
	{{ entity.epochtime }}

The input values for charging end time can be sent to the go-eCharger with the following rest-command:

# go-e set charging autostop time in seconds - v2 api
goecharger_set_autostop_time_setting:
  url: "http://192.168.X.YYY/api/set?att={{ state_attr('input_datetime.goecharger_autostop_setting', 'timestamp') }}"

To override the charging end-time values with the “green index time” “on click”, you can use a python script to apply the time values to the input-datetime component, or you call another rest-command to set “att” attribute via service (see above) from the row-paper-buttons’ tap_action.

I hope this is helpful for you, details and better solutions can be discussed here.

4 Likes

Just to give those who are searching for it a reference: