Hi all,
While we wait for GivTCP support for the EV charger, I’ve knocked together some config to get the EV charger working in Home Assistant via the cloud API. I will be publishing this in a proper video/article in a few weeks, but I figured it might be useful for other EV charger beta users too. These instructions assume you’re already familiar with Home Assistant and editing the configuration, if you’re not then you may be best off waiting for the proper guide.
Step 1:
- Create an API key via the portal
- Edit secrets.yaml
- Add a line as follows and save:
givenergy_apikey: "Bearer YOUR_API_KEY"
Step 2:
- Paste the below into configuration.yaml (or rearrange into your sections as required) and restart Home Assistant.
rest:
- resource_template: 'https://api.givenergy.cloud/v1/ev-charger?page=1'
scan_interval: 15
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
sensor:
- name: "GivEnergy EV Status"
unique_id: givenergy_ev_status
value_template: '{{ value_json.data[0].status }}'
- name: "GivEnergy EV UUID"
unique_id: givenergy_ev_uuid
value_template: '{{ value_json.data[0].uuid }}'
- resource_template: 'https://api.givenergy.cloud/v1/ev-charger/{{ states("sensor.givenergy_ev_uuid") }}/meter-data?start_time={{ (utcnow() - timedelta( minutes = 1 )).strftime("%Y-%m-%dT%H:%M:%SZ") }}&end_time={{ utcnow().strftime("%Y-%m-%dT%H:%M:%SZ") }}&measurands[]=13&meter_ids[]=0&page=1&pageSize=1'
scan_interval: 60
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
sensor:
- name: "GivEnergy EV Power"
unique_id: givenergy_ev_power
value_template: '{{ value_json.data[0].measurements[0].value }}'
device_class: 'power'
state_class: 'measurement'
unit_of_measurement: 'kW'
- resource_template: 'https://api.givenergy.cloud/v1/ev-charger/{{ states("sensor.givenergy_ev_uuid") }}/meter-data?start_time={{ (utcnow() - timedelta( minutes = 1 )).strftime("%Y-%m-%dT%H:%M:%SZ") }}&end_time={{ utcnow().strftime("%Y-%m-%dT%H:%M:%SZ") }}&measurands[]=4&meter_ids[]=0&page=1&pageSize=1'
scan_interval: 300
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
sensor:
- name: "GivEnergy EV Energy"
unique_id: givenergy_ev_energy
value_template: '{{ value_json.data[0].measurements[0].value }}'
device_class: 'energy'
state_class: 'total_increasing'
unit_of_measurement: 'Wh'
- resource_template: 'https://api.givenergy.cloud/v1/ev-charger/{{ states("sensor.givenergy_ev_uuid") }}/commands/change-mode/'
scan_interval: 15
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
sensor:
- name: "GivEnergy EV Mode"
unique_id: givenergy_ev_mode
value_template: >-
{% if value_json.data[0].active %}
Eco+
{% elif value_json.data[1].active %}
Eco
{% elif value_json.data[2].active %}
Boost
{% else %}
Unknown
{% endif %}
- resource_template: 'https://api.givenergy.cloud/v1/ev-charger/{{ states("sensor.givenergy_ev_uuid") }}/commands/set-plug-and-go/'
scan_interval: 15
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
binary_sensor:
- name: "GivEnergy EV Plug And Go State"
unique_id: givenergy_ev_plugandgo_state
value_template: '{{ value_json.data.value }}'
rest_command:
givenergy_ev_setmode:
url: 'https://api.givenergy.cloud/v1/ev-charger/{{ states("sensor.givenergy_ev_uuid") }}/commands/change-mode'
method: POST
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
payload: '{"mode": "{{ mode }}"}'
givenergy_ev_setplugandgo:
url: 'https://api.givenergy.cloud/v1/ev-charger/{{ states("sensor.givenergy_ev_uuid") }}/commands/set-plug-and-go/'
method: POST
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
payload: '{"enabled": {{ enabled }}}'
givenergy_ev_startcharge:
url: 'https://api.givenergy.cloud/v1/ev-charger/{{ states("sensor.givenergy_ev_uuid") }}/commands/start-charge'
method: POST
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
givenergy_ev_stopcharge:
url: 'https://api.givenergy.cloud/v1/ev-charger/{{ states("sensor.givenergy_ev_uuid") }}/commands/stop-charge'
method: POST
headers:
Authorization: !secret givenergy_apikey
Accept: "application/json"
Content-Type: "application/json"
switch:
- platform: template
switches:
givenergy_ev_mode_eco:
friendly_name: "GivEnergy EV Mode: Eco"
value_template: "{{ is_state('sensor.givenergy_ev_mode', 'Eco') }}"
turn_on:
service: rest_command.givenergy_ev_setmode
data:
mode: Eco
turn_off:
service: rest_command.givenergy_ev_setmode
data:
mode: Eco
givenergy_ev_mode_ecoplus:
friendly_name: "GivEnergy EV Mode: Eco+"
value_template: "{{ is_state('sensor.givenergy_ev_mode', 'Eco+') }}"
turn_on:
service: rest_command.givenergy_ev_setmode
data:
mode: SuperEco
turn_off:
service: rest_command.givenergy_ev_setmode
data:
mode: SuperEco
givenergy_ev_mode_boost:
friendly_name: "GivEnergy EV Mode: Boost"
value_template: "{{ is_state('sensor.givenergy_ev_mode', 'Boost') }}"
turn_on:
service: rest_command.givenergy_ev_setmode
data:
mode: Boost
turn_off:
service: rest_command.givenergy_ev_setmode
data:
mode: Boost
givenergy_ev_plugandgo:
friendly_name: "GivEnergy EV Plug&Go"
value_template: "{{ is_state('binary_sensor.givenergy_ev_plug_and_go_state', 'on') }}"
turn_on:
service: rest_command.givenergy_ev_setplugandgo
data:
enabled: "true"
turn_off:
service: rest_command.givenergy_ev_setplugandgo
data:
enabled: "false"
givenergy_ev_chargingstopstart:
friendly_name: "GivEnergy EV Charging Stop/Start"
value_template: "{{ is_state('sensor.givenergy_ev_status', 'Charging') }}"
turn_on:
service: rest_command.givenergy_ev_startcharge
data: {}
turn_off:
service: rest_command.givenergy_ev_stopcharge
data: {}
template:
binary_sensor:
- name: "GivEnergy EV Charger Connected"
state: >-
{% if is_state('sensor.givenergy_ev_status','Preparing') %}true
{% elif is_state('sensor.givenergy_ev_status','Charging') %}true
{% elif is_state('sensor.givenergy_ev_status','SuspendedEVSE') %}true
{% elif is_state('sensor.givenergy_ev_status','SuspendedEV') %}true
{% elif is_state('sensor.givenergy_ev_status','Finishing') %}true
{% endif %}
Step 3:
- Create an entities card with all of the following controls on:
type: entities
entities:
- entity: switch.givenergy_ev_plugandgo
- entity: binary_sensor.givenergy_ev_plug_and_go_state
- entity: switch.givenergy_ev_mode_ecoplus
- entity: switch.givenergy_ev_mode_eco
- entity: switch.givenergy_ev_mode_boost
- entity: sensor.givenergy_ev_mode
- entity: sensor.givenergy_ev_status
- entity: binary_sensor.givenergy_ev_charger_connected
- entity: switch.givenergy_ev_chargingstopstart
- entity: sensor.givenergy_ev_energy