Hi, the following package is something I worked on for weeks and this has in fact worked just fine for 2 years. Since on off the last HA updates it does not work correctly anymore.
The package controls a Simple EVSE Wifi electric car charger.
When enabling the 2 scored out rest sensors, the charger will switch itself off, just 20-30 seconds after switching it on.
I have been disabling parts of the package in order to find out what exactly causes the issue. But no luck so far. It seems like doing multiple “getParameters” requests will fail. The issue is not related to the automations.
Does anyone know how to could limit the amount of “getParameters” requests and cache the data somehow and use that cached data to create the other sensors as a template sensor?
Given the time it took me to put this together I need some specific help, my programming skills are no that good 
#### Calling: http://192.168.207.98/getParameters gives me:
{"type":"parameters","list":[{"vehicleState":2,"evseState":false,"maxCurrent":20,"actualCurrent":18,"actualPower":0,"duration":0,"alwaysActive":false,"lastActionUser":"","lastActionUID":"","energy":0,"mileage":0,"meterReading":0,"currentP1":0,"currentP2":0,"currentP3":0}]}
#############################################################
# Simple EVSE Wallbox Wifi package #
# https://github.com/CurtRod/SimpleEVSE-WiFi #
#############################################################
#### Set charging amp limits
input_number:
evse_max_amps:
name: "Maximale laadstroom"
min: 6
max: 20
evse_max_charge_distance:
name: "Maximaal bijladen"
min: 20
max: 270
step: 10
#### Set max amps
rest_command:
evse_set_max_amps:
url: "http://192.168.207.98/setCurrent?current={{ states.input_number.evse_max_amps.state }}"
#### Activate EVSE
switch:
- platform: command_line
switches:
evse:
friendly_name: EVSE activeren
command_on: "curl http://192.168.207.98/setStatus?active=true"
command_off: "curl http://192.168.207.98/setStatus?active=false"
command_state: "/usr/bin/curl -X GET http://192.168.207.98/getParameters"
value_template: "{{ value_json.list[0].evseState == True}}"
#### sensors
sensor:
- platform: rest
name: EVSE Vehicle state
resource: http://192.168.207.98/getParameters
value_template: "{{ value_json.list[0].vehicleState }}"
method: GET
timeout: 30
force_update: true
- platform: template
sensors:
evse_vehicle_state_templated:
value_template: >-
{% if is_state('sensor.evse_vehicle_state', '1') %}
Niet verbonden
{% elif is_state('sensor.evse_vehicle_state', '2') %}
Verbonden
{% elif is_state('sensor.evse_vehicle_state', '3') %}
Laadt...
{% endif %}
icon_template: >-
{% if is_state('sensor.evse_vehicle_state', '1') %}
mdi:car
{% elif is_state('sensor.evse_vehicle_state', '2') %}
mdi:car-connected
{% elif is_state('sensor.evse_vehicle_state', '3') %}
mdi:ev-station
{% endif %}
- platform: rest
name: EVSE state
resource: http://192.168.207.98/getParameters
value_template: "{{ value_json.list[0].evseState }}"
method: GET
timeout: 30
force_update: true
- platform: rest
name: EVSE Actual current
resource: http://192.168.207.98/getParameters
value_template: "{{ value_json.list[0].actualCurrent }}"
unit_of_measurement: "A"
method: GET
timeout: 30
force_update: true
- platform: rest
name: EVSE power
resource: http://192.168.207.98/getParameters
value_template: "{{ value_json.list[0].actualPower }}"
unit_of_measurement: "kW"
method: GET
timeout: 30
force_update: true
- platform: rest
name: EVSE Duration
resource: http://192.168.207.98/getParameters
value_template: "{{ value_json.list[0].duration }}"
method: GET
timeout: 30
force_update: true
- platform: template
sensors:
evse_duration_templated:
value_template: >-
{% set uptime = states.sensor.evse_duration.state | float * 1 / 60000 | int %}
{% set minutes = ((uptime % 60) / 1) | int %}
{% set hours = ((uptime % 1440) / 60) | int %}
{% set days = (uptime /1440) | int %}
{%- if uptime < 1 -%}
Minder dan één minuut
{%- else -%}
{%- if days > 0 -%}
{%- if days == 1 -%}
1 dag
{%- else -%}
{{ days }} dagen
{%- endif -%}
{%- endif -%}
{%- if hours > 0 -%}
{%- if days > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if hours == 1 -%}
1 uur
{%- else -%}
{{ hours }} uren
{%- endif -%}
{%- endif -%}
{%- if minutes > 0 -%}
{%- if days > 0 or hours > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes == 1 -%}
1 minuut
{%- else -%}
{{ minutes }} minuten
{%- endif -%}
{%- endif -%}
{%- endif -%}
# - platform: rest
# name: EVSE Energy
# resource: http://192.168.207.98/getParameters
# value_template: "{{ value_json.list[0].energy }}"
# method: GET
# timeout: 30
# force_update: true
#
# - platform: rest
# name: EVSE Charged Mileage
# resource: http://192.168.207.98/getParameters
# value_template: "{{ value_json.list[0].mileage }}"
# unit_of_measurement: "Km"
# method: GET
# timeout: 30
# force_update: true
##### customizations
homeassistant:
customize:
sensor.evse_vehicle_state_templated:
friendly_name: Status
input_number.evse_max_amps:
friendly_name: Max. stroom
icon: mdi:flash-circle
unit_of_measurement: A
persistent: true
input_number.evse_max_charge_distance:
persistent: true
sensor.evse_power:
friendly_name: Actueel laadvermogen
icon: mdi:power-socket
sensor.evse_duration_templated:
friendly_name: Tijd geactiveerd
icon: mdi:progress-clock
sensor.evse_energy:
friendly_name: Energie
icon: mdi:download
sensor.evse_charged_milage:
friendly_name: Opgeladen bereik
icon: mdi:map-marker-distance
switch.evse:
friendly_name: Lader activeren
icon: mdi:ev-station
persistent: true
##### Automations
automation:
## set max amps
- id: evse_set_max_amps
alias: EVSE set max amps
trigger:
platform: state
entity_id: input_number.evse_max_amps
action:
service: rest_command.evse_set_max_amps
- id: evse_inschakelen_na_2200
alias: EVSE inschakelen na 22.00uur
trigger:
platform: time
at: "22:00:00"
condition:
- condition: state
entity_id: binary_sensor.leaf1mich_plug_status
state: "on"
action:
- service: switch.turn_on
entity_id: switch.evse
- id: evse_uitschakelen_indien_bijgeladen_afstand_behaald
alias: EVSE uitschakelen indien bijgeladen afstand behaald
trigger:
platform: template
value_template: "{{ states('sensor.evse_charged_milage') |int > states('input_number.evse_max_charge_distance')| int}}"
condition:
- condition: numeric_state
entity_id: sensor.evse_vehicle_state
above: 1
action:
- service: switch.turn_off
entity_id: switch.evse
## notify on full battery
- id: evse_thuis_accu_vol
alias: EVSE thuis notificatie indien accu vol
trigger:
platform: state
entity_id: sensor.leaf1mich_charge
to: "100"
action:
- service: notify.mobile_app_iphone_van_michel
data_template:
title: "Auto accu vol!"
message: "Huidig accu percentage {{ states.sensor.leaf1mich_charge.state }}%"
data:
push:
sound: "auto_volledig_opgeladen.mp3"
attachment:
content-type: jpeg
url: !secret image_url_car-charge
## notify on charge start
- id: evse_laadsessie_gestart_notificatie
alias: EVSE laadsessie gestart notificatie
trigger:
platform: state
entity_id: sensor.evse_vehicle_state
to: "3"
action:
- service: notify.mobile_app_iphone_van_michel
data_template:
title: "Auto laad op"
message: "Laadsessie Leaf gestart, accu {{ states.sensor.leaf1mich_charge.state }}%"
data:
push:
sound: "auto_laad.mp3"
attachment:
content-type: jpeg
url: !secret image_url_car-charge
## notify on charge stop
- id: evse_laadsessie_gestopt_notificatie
alias: EVSE laadsessie gestopt notificatie
trigger:
platform: state
entity_id: switch.evse
to: "off"
condition:
- condition: numeric_state
entity_id: sensor.leaf1mich_charge
below: 99
action:
- service: notify.mobile_app_iphone_van_michel
data_template:
title: "Auto laadsessie beëindigd!"
message: "Laadsessie Leaf beëindigd, accu {{ states.sensor.leaf1mich_charge.state }}%"
data:
push:
sound: "auto_laadsessie_beeindigd.mp3"
attachment:
content-type: jpeg
url: !secret image_url_car-charge


