Skip to content

Instantly share code, notes, and snippets.

@mathieucarbou
Last active October 20, 2024 21:54
Show Gist options
  • Save mathieucarbou/92a3d5e0dc38d6b68aa1bdaf153a80c5 to your computer and use it in GitHub Desktop.
Save mathieucarbou/92a3d5e0dc38d6b68aa1bdaf153a80c5 to your computer and use it in GitHub Desktop.
Home Assistant OpenEVSE Integration backed by MQTT

Home Assistant OpenEVSE Integration backed by MQTT

image

Older screenshots

Screenshot 2023-05-22 at 01 43 25 Screenshot 2023-05-22 at 01 43 38 Screenshot 2023-05-22 at 01 44 22

HA Config

In global config:

homeassistant:
  packages: !include_dir_named packages

# https://www.home-assistant.io/integrations/mqtt_statestream
mqtt_statestream:
  base_topic: homeassistant
  publish_attributes: true
  publish_timestamps: true

Then put openevse_*.yaml files in config/packages folder

view.yaml is the Lovelace dashboard section above

openevse_integration.yaml is the one you'll need to customize.

EVSE Config

Screenshot 2023-05-14 at 17 17 39

image

Screenshot 2023-05-14 at 17 18 05

image

Shelly

I am using 2 Shelly EM:

  • One connected to the wire going to the EVSE box, to measure the whole EVSE consumption
  • One for the grid

Downloads

Take v5 firmware or later : https://github.com/OpenEVSE/openevse_esp32_firmware/releases

OpenEVSE: https://www.openevse.com

#
# CALIBRATION
#
# LOSS: https://schema-electrique.net/calcul-chute-de-tension-electrique-formule-calcul-section-cable-triphase-monophase.html
#
# * PERTE Grid - Garage: 2*0.023*10/6 = 0.07666666667
# * PERTE Garage - EVSE: 2*0.023*10/6 = 0.07666666667
# * PERTE EVSE - car: 2*0.023*10/2.5 = 0.184 BUT Measured with OBD: 0.184 * 2
#
# CanZE OBD: verify voltage, current, power
#
# EVSE Calibration: $SA 235 860
#
# Grid : {{ states.sensor.grid_voltage.state }} V
# Suno : {{ states.sensor.sunology_play_voltage.state|float }} V
# Boitier: {{ states.sensor.openevse_voltage.state|float }} V | {{states.sensor.openevse_power.state|float / states.sensor.openevse_power_factor.state|float|abs / (states.sensor.openevse_voltage.state|float)}} A
# Car : {{ states.sensor.openevse_charge_session_voltage.state|float }} V | {{ states.sensor.openevse_charge_session_current.state|float }} A
# Car : {{ states.sensor.openevse_voltage.state|float - (2*0.023*10/6 * 2 + 2*0.023*10/2.5 * 2) * states.sensor.openevse_charge_session_current.state|float }} V | {{ states.sensor.openevse_charge_session_current.state|float }} A
# OBD : {{ states.sensor.openevse_measured_voltage.state|float * 0.975 - (2*0.023*10/6+2*0.023*10/2.5) * states.sensor.openevse_charge_session_current.state|float }} V | {{ states.sensor.openevse_charge_session_current.state }} A
#
# https://www.home-assistant.io/integrations/input_number
input_number:
openevse_power_error:
name: OpenEVSE Power Error
min: 0
max: 2
step: 0.001
mode: box
openevse_voltage_error:
name: OpenEVSE Voltage Error
min: 0
max: 2
step: 0.001
mode: box
template:
# https://www.home-assistant.io/integrations/sensor/
- sensor:
# Shelly EM Measuring EVSE Box with correction factors
- name: OpenEVSE Power
unique_id: B6C139A7-ABBD-4D1F-9115-D9837608F01A
state_class: measurement
device_class: power
unit_of_measurement: W
availability: "{{ ['sensor.openevse_measured_power', 'input_number.openevse_power_error']|map('states')|map('is_number')|min }}"
state: "{{ (states.sensor.openevse_measured_power.state|float * states.input_number.openevse_power_error.state|float) }}"
- name: OpenEVSE Voltage
unique_id: 7A4DE19E-C813-4E9E-A99C-2A898AAB67A3
state_class: measurement
device_class: voltage
unit_of_measurement: V
availability: "{{ ['sensor.openevse_measured_voltage', 'input_number.openevse_voltage_error']|map('states')|map('is_number')|min }}"
state: "{{ (states.sensor.openevse_measured_voltage.state|float * states.input_number.openevse_voltage_error.state|float) }}"
# Correctly computed charge voltage sent to EVSE
- name: OpenEVSE Charge Session Voltage
unique_id: EEFA3D57-EB4D-4E9E-BB63-7795DC28140C
state_class: measurement
device_class: voltage
unit_of_measurement: V
availability: "{{ ['sensor.openevse_voltage', 'sensor.openevse_charge_session_current']|map('states')|map('is_number')|min }}"
state: "{{ states.sensor.openevse_voltage.state|float - (2*0.023*10/6 * 2 + 2*0.023*10/2.5 * 2) * states.sensor.openevse_charge_session_current.state|float }}"
automation:
- alias: "OpenEVSE: Publish Vehicle Data"
max_exceeded: silent
trigger:
- platform: mqtt
topic: "openevse/local_time"
condition: []
action:
- service: mqtt.publish
data:
topic: "homeassistant/states/sensor/renault_zoe_battery_level/state"
payload: "{{states.sensor.renault_zoe_battery_level.state}}"
- service: mqtt.publish
data:
topic: "homeassistant/states/sensor/renault_zoe_battery_autonomy/state"
payload: "{{states.sensor.renault_zoe_battery_autonomy.state}}"
- service: mqtt.publish
data:
topic: "homeassistant/states/sensor/renault_zoe_charging_remaining_time_sec/state"
payload: "{{states.sensor.renault_zoe_charging_remaining_time_sec.state}}"
- alias: "OpenEVSE: Charge HC"
trigger:
- platform: state
entity_id:
- binary_sensor.grid_tarif_hc
condition: []
action:
- if:
- condition: state
entity_id: binary_sensor.grid_tarif_hc
state: "on"
then:
- service: script.openevse_charge_manual
data: {}
else:
- service: script.openevse_charge_auto
data: {}
logbook:
exclude:
entities:
- automation.openevse_publish_vehicle_data
mqtt:
# https://www.home-assistant.io/integrations/sensor.mqtt
sensor:
# OpenEVSE States
- name: OpenEVSE Temperature
unique_id: FB65CAFA-42AF-4AFC-9754-B11A5AB52C21
icon: mdi:thermometer
state_topic: "openevse/temp"
device_class: temperature
state_class: measurement
unit_of_measurement: "°C"
value_template: "{{ value|float / 10.0 }}"
expire_after: 40
- name: OpenEVSE Uptime
unique_id: 55806B85-C3B9-4EF7-8DB3-2E6C28D97669
icon: mdi:clock
state_topic: "openevse/uptime"
device_class: duration
state_class: measurement
unit_of_measurement: s
value_template: "{{ value|int }}"
expire_after: 40
- name: OpenEVSE WiFi Signal
unique_id: AEA6EBA8-6B47-455C-BF9F-AA1597B8F80F
state_topic: "openevse/srssi"
device_class: signal_strength
unit_of_measurement: dB
state_class: measurement
value_template: "{{ value|int }}"
expire_after: 40
- name: OpenEVSE Status
unique_id: 5C6C8534-6CC1-4B8A-9F66-B848473B6C37
state_topic: "openevse/state"
icon: mdi:information
expire_after: 40
value_template: >-
{%- if value | regex_match('^[01]$') -%}
Not Connected
{%- elif value | regex_match('^2$') -%}
Connected
{%- elif value | regex_match('^3$') -%}
Charging
{%- elif value | regex_match('^([456789]|10)$') -%}
Error ({{ value }})
{%- elif value | regex_match('^254$') -%}
Sleeping
{%- elif value | regex_match('^255$') -%}
Disabled
{%- else -%}
Unknown ({{ value }})
{%- endif -%}
# OpenEVSE Charge Control
- name: OpenEVSE Charge Pilot Max
unique_id: 870845EB-0C80-499A-964A-42FA9094165D
state_topic: "openevse/max_current"
device_class: current
state_class: measurement
unit_of_measurement: "A"
value_template: "{{ value|int }}"
expire_after: 40
# OpenEVSE Meters
- name: OpenEVSE Energy Total
unique_id: 38D03D62-73D2-408C-AF11-7D656267BE36
state_topic: "openevse/total_energy"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
value_template: "{{ value|float }}"
- name: OpenEVSE Energy Daily
unique_id: EE072374-3D05-47BC-8F2D-1EFE91744EED
state_topic: "openevse/total_day"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
value_template: "{{ value|float }}"
- name: OpenEVSE Energy Weekly
unique_id: CB4A849A-E4C7-442F-9F4F-8E80285C0547
state_topic: "openevse/total_week"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
value_template: "{{ value|float }}"
- name: OpenEVSE Energy Monthly
unique_id: 137871B7-0C26-4312-8E52-C374339A0EDE
state_topic: "openevse/total_month"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
value_template: "{{ value|float }}"
- name: OpenEVSE Energy Yearly
unique_id: C16BBC78-C938-4DD0-A67E-17782E078197
state_topic: "openevse/total_year"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
value_template: "{{ value|float }}"
- name: OpenEVSE Total Relay Switches
unique_id: 78C1ADAB-6037-4BF8-99F9-50D04391A35E
state_topic: "openevse/total_switches"
state_class: total_increasing
value_template: "{{ value|int }}"
# OpenEVSE Solar Divert
- name: OpenEVSE Solar Divert Mode
unique_id: C144A777-4BA0-4C1A-882D-EAF130C1F96A
icon: mdi:information
state_topic: "openevse/config"
value_template: "{{ 'Production' if value_json.divert_type == 0 else 'Export' if value_json.divert_type == 1 else 'Unset' }}"
- name: OpenEVSE Solar Divert Grid I/E Power
unique_id: 5F5849C7-9D71-4805-B1AA-1A14B7A225E8
state_topic: "openevse/grid_ie"
device_class: power
state_class: measurement
unit_of_measurement: W
value_template: "{{ value|float }}"
expire_after: 40
- name: OpenEVSE Solar Divert Trigger Current
unique_id: 5B796C33-EB58-4ED8-B6CE-FAFF571BC716
state_topic: "openevse/trigger_current"
device_class: current
state_class: measurement
unit_of_measurement: "A"
value_template: "{{ value|float }}"
expire_after: 40
- name: OpenEVSE Solar Divert Smoothed Available Current
unique_id: 352FC91A-FAC3-49B8-9F73-A783A53E13B7
state_topic: "openevse/smoothed_available_current"
device_class: current
state_class: measurement
unit_of_measurement: "A"
value_template: "{{ value|float }}"
expire_after: 40
- name: OpenEVSE Solar Divert Available Current
unique_id: 01F32597-A7BA-44F7-9316-082864B422F1
state_topic: "openevse/available_current"
device_class: current
state_class: measurement
unit_of_measurement: "A"
value_template: "{{ value|float }}"
expire_after: 40
- name: OpenEVSE Solar Divert Charge Pilot
unique_id: E562FDD7-06C4-4352-BA84-32E1F881DA40
state_topic: "openevse/charge_rate"
device_class: current
state_class: measurement
unit_of_measurement: "A"
value_template: "{{ value|float }}"
expire_after: 40
- name: OpenEVSE Solar Divert Power Ratio
unique_id: 1F63E35B-A968-4448-80FE-F9D4B86F5408
state_topic: "openevse/config"
value_template: "{{ value_json.divert_PV_ratio|float if value_json.divert_PV_ratio|is_number else 0 }}"
- name: OpenEVSE Solar Divert Minimum Charging Time
unique_id: 0260723C-AF74-4C2B-9C5D-F21A281AD119
state_topic: "openevse/config"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
value_template: "{{ value_json.divert_min_charge_time|int if value_json.divert_min_charge_time|is_number else 0 }}"
- name: OpenEVSE Solar Divert Smoothing Attack
unique_id: E948AD52-3A04-452F-A8D7-F91F0D1C2DA8
state_topic: "openevse/config"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
value_template: "{{ value_json.divert_attack_smoothing_time|int if value_json.divert_attack_smoothing_time|is_number else 0 }}"
- name: OpenEVSE Solar Divert Smoothing Decay
unique_id: 8E661748-5DEF-4E91-A1F1-C6934438A35E
state_topic: "openevse/config"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
value_template: "{{ value_json.divert_decay_smoothing_time|int if value_json.divert_decay_smoothing_time|is_number else 0 }}"
# OpenEVSE Current Shaper
- name: OpenEVSE Current Shaper Load
unique_id: A8D5640E-6F37-4726-8AA2-C5ED09A547FC
state_topic: "openevse/shaper_live_pwr"
device_class: power
state_class: measurement
unit_of_measurement: "W"
value_template: "{{ [0, value|int] | max }}"
expire_after: 40
- name: OpenEVSE Current Shaper Free
unique_id: 50589CB6-A283-4C65-AE7A-19BF284B79FA
state_topic: "openevse/shaper_cur"
device_class: current
state_class: measurement
unit_of_measurement: "A"
value_template: "{{ value|float }}"
expire_after: 40
- name: OpenEVSE Current Shaper Max Power
unique_id: 30705EE3-0E04-4F59-9706-E6CADCD69DE1
state_topic: "openevse/config"
device_class: power
state_class: measurement
unit_of_measurement: "W"
value_template: "{{ value_json.current_shaper_max_pwr|int if value_json.current_shaper_max_pwr|is_number else 0 }}"
# OpenEVSE Charge Session
- name: OpenEVSE Charge Session Elapsed
unique_id: 4F1224CE-8D67-4084-BC5D-6DD54344C17E
icon: mdi:clock
state_topic: "openevse/session_elapsed"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
value_template: "{{ value|int }}"
expire_after: 40
- name: OpenEVSE Charge Session Current
unique_id: F5779F32-60F0-4DD3-A4F9-7C8A61078479
state_topic: "openevse/amp"
device_class: current
state_class: measurement
unit_of_measurement: "A"
value_template: "{{ value|float / 1000.0 }}"
expire_after: 40
- name: OpenEVSE Charge Session Power
unique_id: 25B6FF8C-BABF-4BBA-83C3-608C5DF258CE
state_topic: "openevse/power"
device_class: power
state_class: measurement
unit_of_measurement: "W"
value_template: "{{ value|float }}"
expire_after: 40
- name: OpenEVSE Charge Session Energy
unique_id: E28B246F-9312-4FB6-9DD1-C928E37BB14F
icon: mdi:flash
state_topic: "openevse/session_energy"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
value_template: "{{ value|float / 1000.0 }}"
expire_after: 40
# OpenEVSE Vehicle
- name: OpenEVSE Vehicle Battery Level
unique_id: D339E01F-8D67-4ABC-A7C7-11FB2A2CB137
state_topic: "openevse/battery_level"
device_class: battery
unit_of_measurement: "%"
icon: mdi:battery
value_template: "{{ value|float }}"
availability_topic: "openevse/battery_level"
availability_template: "{{ 'online' if value|is_number and value|float > 0 else 'offline' }}"
expire_after: 40
- name: OpenEVSE Vehicle Autonomy
unique_id: 4315ABAE-A084-402E-BE28-2A58D69E1D56
state_topic: "openevse/battery_range"
device_class: distance
unit_of_measurement: "km"
icon: mdi:sign-direction
value_template: "{{ value|int }}"
availability_topic: "openevse/battery_range"
availability_template: "{{ 'online' if value|is_number and value|int > 0 else 'offline' }}"
expire_after: 40
- name: OpenEVSE Vehicle Charge Remaining Time
unique_id: 8FF37A72-D238-4BA3-93E3-1FB63C3C884A
state_topic: "openevse/time_to_full_charge"
device_class: duration
unit_of_measurement: "s"
icon: mdi:clock
value_template: "{{ value|int }}"
availability_topic: "openevse/battery_level"
availability_template: "{{ 'online' if value|is_number and value|float > 0 else 'offline' }}"
expire_after: 40
# OpenEVSE Config
- name: OpenEVSE Config
unique_id: FD00ADC3-1761-46E0-896D-34252E582413
state_topic: "openevse/config_version"
value_template: "{{ value|int }}"
json_attributes_topic: "openevse/config"
icon: mdi:information
# https://www.home-assistant.io/integrations/binary_sensor.mqtt
binary_sensor:
- name: OpenEVSE Solar Divert Allow Charge
unique_id: 703CE4A8-F919-4FCD-A62F-10AED23FA85C
icon: mdi:check-circle
state_topic: "openevse/divert_active"
payload_on: "true"
payload_off: "false"
expire_after: 40
- name: OpenEVSE Vehicle Connected
unique_id: 38AFB454-9EE7-4FA9-BF7D-93A93351B72B
icon: mdi:ev-plug-type2
state_topic: "openevse/vehicle"
payload_on: "1"
payload_off: "0"
expire_after: 40
# https://www.home-assistant.io/integrations/switch.mqtt/
switch:
- name: OpenEVSE Solar Divert
unique_id: DBA9BF34-1990-4B45-B5D6-5D4560CD3767
icon: mdi:solar-panel
state_topic: "openevse/config"
value_template: "{{ 'on' if value_json.divert_enabled else 'off' }}"
command_topic: "openevse/config/set"
state_on: "on"
state_off: "off"
payload_on: '{"divert_enabled":true}'
payload_off: '{"divert_enabled":false}'
- name: OpenEVSE Current Shaper
unique_id: 4B099CDD-398D-489E-8E19-0A419FE297B7
icon: mdi:car-speed-limiter
state_topic: "openevse/config"
value_template: "{{ 'on' if value_json.current_shaper_enabled else 'off' }}"
command_topic: "openevse/config/set"
state_on: "on"
state_off: "off"
payload_on: '{"current_shaper_enabled":true}'
payload_off: '{"current_shaper_enabled":false}'
# https://www.home-assistant.io/integrations/select.mqtt/
select:
# OpenEVSE Charge Control
- name: OpenEVSE Charge Control
unique_id: 356932F4-436F-4C4B-A405-56BF65338E54
icon: mdi:robot
state_topic: "openevse/manual_override"
command_topic: "openevse/override/set"
options:
- Auto
- Manual
value_template: "{{ 'Manual' if value == '1' else 'Auto' }}"
command_template: >-
{% if value == 'Auto' %}
clear
{% else %}
{"state": "{{'active' if states.select.openevse_charge_status.state == 'Allow Charge' else 'disabled'}}", "charge_current": {{states.number.openevse_charge_pilot.state}}, "auto_release": true}
{% endif %}
- name: OpenEVSE Charge Status
unique_id: C19541CF-1B64-463D-8655-E0CC8ADE8BE6
icon: mdi:battery-charging
state_topic: "openevse/status"
command_topic: "openevse/override/set"
options:
- Allow Charge
- Pause Charge
value_template: "{{'Allow Charge' if value == 'active' else 'Pause Charge'}}"
command_template: >-
{"state": "{{'active' if value == 'Allow Charge' else 'disabled'}}", "charge_current": {{states.number.openevse_charge_pilot.state}}, "auto_release": true}
- name: OpenEVSE Charge Limit
unique_id: 71271DE5-6AE4-475A-A4F9-F202F922E9C1
icon: mdi:car-speed-limiter
state_topic: "openevse/limit"
command_topic: "openevse/limit/set"
options:
- No Limit
- Battery 90%
value_template: >-
{{ 'No Limit' if value_json.type == 'none' or value_json.Type == 'none' or value == 'false' else 'Battery 90%' if value_json.type == 'soc' and value_json.value == 90 else states.select.openevse_charge_limit.state if value == 'true' else value }}
command_template: >-
{% if value == 'No Limit' %}
clear
{% else %}
{"type": "soc", "value": 90, "auto_release": true}
{% endif %}
# https://www.home-assistant.io/integrations/button.mqtt/
button:
- name: OpenEVSE Restart Gateway
unique_id: 76D7ED73-8131-4FCC-9B3B-CBF482F625F1
icon: mdi:restart
command_topic: "openevse/restart"
payload_press: '{"device":"gateway"}'
- name: OpenEVSE Restart EVSE
unique_id: 55C77E3B-AD00-4376-B69B-7F7BC4AB8C38
icon: mdi:restart
command_topic: "openevse/restart"
payload_press: '{"device":"evse"}'
# https://www.home-assistant.io/integrations/number.mqtt/
number:
# charge
- name: OpenEVSE Charge Pilot
unique_id: 4A4EE63B-B87A-479D-AF38-8011C710F852
state_topic: "openevse/pilot"
device_class: current
unit_of_measurement: "A"
value_template: "{{ [32, [6, value|int] | max] | min if value|is_number else 0 }}"
min: 6
max: 32
step: 1
mode: slider
command_topic: "openevse/override/set"
command_template: >-
{"state": "{{'active' if states.select.openevse_charge_status.state == 'Allow Charge' else 'disabled'}}", "charge_current": {{value}}, "auto_release": true}
# evse
- name: OpenEVSE Max Pilot Soft
unique_id: 51E920C1-4C35-437A-947C-81E2B29A384C
state_topic: "openevse/config"
device_class: current
unit_of_measurement: "A"
value_template: >-
{{ value_json.max_current_soft|int if value_json.max_current_soft|is_number else 6 }}
min: 6
max: 32
step: 1
mode: slider
command_topic: "openevse/config/set"
command_template: >-
{"max_current_soft": "{{value}}"}
# https://www.home-assistant.io/integrations/timer
timer:
openevse_shutdown_detection:
name: "OpenEVSE Shutdown Detection"
template:
# https://www.home-assistant.io/integrations/binary_sensor
- binary_sensor:
- name: OpenEVSE Gateway
unique_id: 95DFB8A2-5984-4D65-B7AC-05E1DE0F1918
device_class: running
icon: mdi:ev-station
state: "{{ states.timer.openevse_shutdown_detection.state == 'active' }}"
- name: OpenEVSE Vehicle Charge
unique_id: 4A22FA51-0861-44F9-9C7F-A3328D45DFDD
device_class: battery_charging
state: "{{ states.sensor.openevse_charge_session_power.state|float(0) > 10 }}"
icon: mdi:battery-charging
script:
openevse_charge_manual:
alias: "OpenEVSE: Charge Manual"
sequence:
- service: select.select_option
data:
option: Manual
target:
entity_id: select.openevse_charge_control
- wait_template: "{{states.select.openevse_charge_control.state == 'Manual'}}"
continue_on_timeout: false
- service: select.select_option
data:
option: Allow Charge
target:
entity_id: select.openevse_charge_status
- wait_template: "{{states.select.openevse_charge_status.state == 'Allow Charge'}}"
continue_on_timeout: false
- service: number.set_value
data:
value: "{{states.number.openevse_max_pilot_soft.state}}"
target:
entity_id: number.openevse_charge_pilot
- service: select.select_option
data:
option: Battery 90%
target:
entity_id: select.openevse_charge_limit
- wait_template: "{{states.select.openevse_charge_limit.state == 'Battery 90%'}}"
continue_on_timeout: false
openevse_charge_auto:
alias: "OpenEVSE: Charge Auto"
sequence:
- service: select.select_option
data:
option: Auto
target:
entity_id: select.openevse_charge_control
- wait_template: "{{states.select.openevse_charge_control.state == 'Auto'}}"
continue_on_timeout: false
- service: select.select_option
data:
option: No Limit
target:
entity_id: select.openevse_charge_limit
- wait_template: "{{states.select.openevse_charge_limit.state == 'No Limit'}}"
continue_on_timeout: false
openevse_charge_switch:
alias: "OpenEVSE: Charge Switch"
sequence:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.openevse_vehicle_charge
state: "on"
sequence:
- service: script.openevse_charge_auto
data: {}
- conditions:
- condition: state
entity_id: binary_sensor.openevse_vehicle_charge
state: "off"
sequence:
- service: script.openevse_charge_manual
data: {}
automation:
- alias: "OpenEVSE: Keep Alive"
max_exceeded: silent
trigger:
- platform: mqtt
topic: "openevse/uptime"
condition: []
action:
- service: timer.start
data:
duration: "00:00:40"
target:
entity_id: timer.openevse_shutdown_detection
- alias: "OpenEVSE: Remove Limit"
max_exceeded: silent
trigger:
- platform: state
entity_id: select.openevse_charge_control
to: "Auto"
condition: []
action:
- service: select.select_option
data:
option: No Limit
target:
entity_id: select.openevse_charge_limit
- wait_template: "{{states.select.openevse_charge_limit.state == 'No Limit'}}"
continue_on_timeout: false
# - alias: "OpenEVSE: Switch Soalr Divert"
# max_exceeded: silent
# trigger:
# - platform: state
# entity_id: binary_sensor.openevse_vehicle_connected
# condition: []
# action:
# - if:
# - condition: state
# entity_id: binary_sensor.openevse_vehicle_connected
# state: "on"
# then:
# - service: switch.turn_on
# data: {}
# target:
# entity_id: switch.openevse_solar_divert
# - service: select.select_option
# data:
# option: Auto
# target:
# entity_id: select.openevse_charge_control
# - wait_template: "{{states.select.openevse_charge_control.state == 'Auto'}}"
# continue_on_timeout: true
# else:
# - service: select.select_option
# data:
# option: Pause Charge
# target:
# entity_id: select.openevse_charge_status
# - wait_template: "{{states.select.openevse_charge_status.state == 'Pause Charge'}}"
# continue_on_timeout: true
# - service: switch.turn_off
# data: {}
# target:
# entity_id: switch.openevse_solar_divert
logbook:
exclude:
entities:
- automation.openevse_keep_alive
- title: OpenEVSE
path: openevse
icon: mdi:ev-station
badges: []
cards:
- type: entities
entities:
- entity: binary_sensor.openevse_gateway
name: Gateway
- entity: button.openevse_restart_gateway
name: Restart Gateway
- entity: button.openevse_restart_evse
name: Restart EVSE
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
row:
entity: number.openevse_max_pilot_soft
name: Max Pilot Soft
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
row:
type: divider
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
row:
entity: sensor.openevse_status
name: Status
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
row:
entity: sensor.openevse_uptime
name: Uptime
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
row:
entity: sensor.openevse_temperature
name: Temperature
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
row:
entity: sensor.openevse_total_relay_switches
name: Total Relay Switches
state_color: true
title: OpenEVSE
show_header_toggle: false
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
card:
type: entities
entities:
- entity: switch.openevse_current_shaper
name: Enable
- type: conditional
conditions:
- entity: switch.openevse_current_shaper
state: 'on'
row:
entity: sensor.openevse_current_shaper_max_power
name: Max Power
- type: conditional
conditions:
- entity: switch.openevse_current_shaper
state: 'on'
row:
type: divider
- type: conditional
conditions:
- entity: switch.openevse_current_shaper
state: 'on'
row:
entity: sensor.openevse_current_shaper_load
name: Load
- type: conditional
conditions:
- entity: switch.openevse_current_shaper
state: 'on'
row:
entity: sensor.openevse_current_shaper_free
name: Free
title: Current Shaper
state_color: true
show_header_toggle: false
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
card:
type: entities
entities:
- entity: switch.openevse_solar_divert
name: Enable
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: binary_sensor.openevse_solar_divert_allow_charge
name: Allow Charge
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: sensor.openevse_solar_divert_mode
name: Mode
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
- entity: sensor.openevse_solar_divert_mode
state: Export
row:
entity: sensor.openevse_solar_divert_grid_i_e_power
name: Grid I/E Power
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
- entity: sensor.openevse_solar_divert_mode
state: Production
row:
entity: sensor.openevse_solar_divert_production_power
name: Production Power
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
type: divider
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: sensor.openevse_solar_divert_power_ratio
name: Power Ratio
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: sensor.openevse_solar_divert_minimum_charging_time
name: Min. Charge
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: sensor.openevse_solar_divert_smoothing_attack
name: Smoothing Attack
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: sensor.openevse_solar_divert_smoothing_decay
name: Smoothing Decay
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
type: divider
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: sensor.openevse_solar_divert_trigger_current
name: Trigger Current
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: sensor.openevse_solar_divert_smoothed_available_current
name: Smoothed Current
- type: conditional
conditions:
- entity: switch.openevse_solar_divert
state: 'on'
row:
entity: sensor.openevse_solar_divert_charge_pilot
name: Pilot
title: Solar Divert
state_color: true
show_header_toggle: false
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
card:
type: entities
entities:
- entity: select.openevse_charge_control
name: Charge Control
- entity: select.openevse_charge_status
name: Charge Status
- entity: select.openevse_charge_limit
name: Charge Limit
- entity: number.openevse_charge_pilot
name: Pilot
- entity: sensor.openevse_charge_max_pilot
name: Pilot Max
state_color: true
title: Charge Control
show_header_toggle: false
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
card:
type: entities
entities:
- entity: sensor.openevse_charge_session_voltage
name: Voltage
- entity: sensor.openevse_charge_session_current
name: Current
- entity: sensor.openevse_charge_session_power
name: Power
- entity: sensor.openevse_charge_session_energy
name: Energy
- entity: sensor.openevse_charge_session_elapsed
name: Elapsed
title: Charge Session
state_color: true
show_header_toggle: false
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
card:
type: entities
entities:
- entity: binary_sensor.openevse_vehicle_connected
name: Connected
- entity: binary_sensor.openevse_vehicle_charge
name: Charge
- entity: sensor.openevse_vehicle_battery_level
name: Battery
- entity: sensor.openevse_vehicle_autonomy
name: Autonomy
- entity: sensor.openevse_vehicle_charge_remaining_time
name: Charge Remaining Time
title: Vehicle
state_color: true
show_header_toggle: false
- type: conditional
conditions:
- entity: binary_sensor.openevse_gateway
state: 'on'
card:
type: entities
entities:
- entity: sensor.openevse_energy_daily
name: Daily
- entity: sensor.openevse_energy_weekly
name: Weekly
- entity: sensor.openevse_energy_monthly
name: Monthly
- entity: sensor.openevse_energy_yearly
name: Yearly
- entity: sensor.openevse_energy_total
name: Lifetime
title: Energy
state_color: true
show_header_toggle: false
@mascpinto
Copy link

mascpinto commented Nov 29, 2023

Hi Mathieu, i think the view.yaml that you publish is not the last one, the first screen, or am i wrong? (the last is the first screen?)

@mathieucarbou
Copy link
Author

Hi Mathieu, i think the view.yaml that you publish is not the last one, the first screem, or am i wrong? (the last is the first screen?)

The code is updated but the screenshots not: the only change if I remember is the addition of the switch count. I don't update the screenshots for such minimal change.

@doppiaemme
Copy link

Hi, I have only seen now your work, very interesting.
I wanted to ask you if there is a specific reason why you use MQTT directly and not the integration already available for OpenEVSE
https://github.com/firstof9/openevse

I am interested in the automation you have built on top of it

@mathieucarbou
Copy link
Author

mathieucarbou commented Apr 18, 2024

@doppiaemme I know this project. But at that time, it was very limited because MQTT / ws / http api in OpenEVSE was very limited. I also don't like to rely on http com (prefer mqtt) and if I remember the project was relying on the http api before (not ws).

I contributed to OpenEVSE codebase to add a correct MQTT support for sensors but also config (I refactored their config system). This was a first basic requirement to get a nice HA integration (OpenEVSE devs are sadly not knowledgeable about HA).
Then I proposed these packages files.

I didn't want to participate in the HA plugin dev because I prefer the flexibility of yaml code and package. The plugin might be nice for someone who is satisfied with limited features, but at the time it was too limited. I hope that since my changes in OpenEVSE codebase, the plugin has improved. But with such plugin, you are limited to what the dev exposes.

And I didn't want also to contribute a HA discovery implementation directly in OpenEVSE for the sane reasons: an HA discovery impl would probably limit to the bare minimum and would not allow more flexibility.

So I find this alternate approach with packages more flexible and easier to adapt to our need by commenting out sections and sensors, and also include some scrips and automations.

There are many ways to make it better also by grouping these templates per device, like an HA discovery impl would do, but I didn't do it.

I think that the nature of OpenEVSE bing already quite a geek-style EVSE car charger, any geek using HA should be clever enough to understand this gist and adapt ;-)

[edit]

I've looked at the commit history in the plugin and I am pleased to see it has been updated a lot to reflect the current OpenEVSE state :-)

@doppiaemme
Copy link

Yes indeed it works quite nice at the moment, I was using MQTT myself directly but an integration is just easier as it provides all the buttons, switches etc already set.

What I am trying to do at the moment is to implement an alternative to the self-production auto adjustment that is in OpenEvse.
I find it so unreliable and it would make more sense to keep it in HA and leave the wallbox to do only on/off.
I saw yours and I also saw someone else doing that but via OCPP instead of MQTT.

@e2thenegpii
Copy link

@mathieucarbou would you mind sharing the configuration for the binary_sensor.grid_tarif_hc and the related scripts script.openevse_charge_manual, and script.openevse_charge_auto? My utility provider doesn't charge the high time of use rates on national holidays so I'm looking to use HA to enable auto charging on those days. But I have limited experience with HA and its automations.

But otherwise this is great work, Thanks.

  - alias: "OpenEVSE: Charge HC"
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.grid_tarif_hc
    condition: []
    action:
      - if:
          - condition: state
            entity_id: binary_sensor.grid_tarif_hc
            state: "on"
        then:
          - service: script.openevse_charge_manual
            data: {}
        else:
          - service: script.openevse_charge_auto
            data: {}

@mathieucarbou
Copy link
Author

@e2thenegpii : everything is there already, but I have just updated the files to their latest version.

@e2thenegpii
Copy link

I see them now, I just needed to look a little harder, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment