Skip to content

Instantly share code, notes, and snippets.

@AMajland
Last active April 19, 2025 06:11
Show Gist options
  • Select an option

  • Save AMajland/6ffc6814df2a92e99cff2c901447efee to your computer and use it in GitHub Desktop.

Select an option

Save AMajland/6ffc6814df2a92e99cff2c901447efee to your computer and use it in GitHub Desktop.
# Automations.yaml
alias: PV to EV Dynamic
trigger:
- platform: time_pattern
seconds: /20
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_select.ev_test_charge
state: Solar 3 Phase
sequence:
- service: easee.set_circuit_dynamic_limit
data:
charger_id: CHARGERID
currentP1: >-
{% set min_voltage =
min(states('sensor.ams_cf58_u1'),states('sensor.ams_cf58_u2'),states('sensor.ams_cf58_u3'))
%} {% set current = ( ((states('sensor.pv_to_ev_power') | float)
) / (min_voltage | float ) / 3.0 + 0.5) %} {%if current < 6.0
%}{% set current = 6.0 %} {% endif %} {{ current }}
currentP2: >-
{% set min_voltage =
min(states('sensor.ams_cf58_u1'),states('sensor.ams_cf58_u2'),states('sensor.ams_cf58_u3'))
%} {% set current = ( ((states('sensor.pv_to_ev_power') | float)
) / (min_voltage | float ) / 3.0 + 0.5) %} {%if current < 6.0
%}{% set current = 6.0 %} {% endif %} {{ current }}
currentP3: >-
{% set min_voltage =
min(states('sensor.ams_cf58_u1'),states('sensor.ams_cf58_u2'),states('sensor.ams_cf58_u3'))
%} {% set current = ( ((states('sensor.pv_to_ev_power') | float)
) / (min_voltage | float ) / 3.0 + 0.5) %} {%if current < 6.0
%}{% set current = 6.0 %} {% endif %} {{ current }}
time_to_live: "1"
- conditions:
- condition: state
entity_id: input_select.ev_test_charge
state: Solar 1 Phase
sequence:
- service: easee.set_circuit_dynamic_limit
data:
charger_id: CHARGERID
currentP1: >-
{% set current = ( ((states('sensor.pv_to_ev_power') | float) ) / (states('sensor.ams_cf58_u1') | float) ) + 1.4 %}
{%if current > 16.0 %}{% set current = 16.0 %}
{% endif %}
{{ current }}
currentP2: "0"
currentP3: "0"
time_to_live: "1"
mode: single
alias: PV to EV Phases
description: >-
Change 1 to 3 phases - check every 1 min. 10min min for 10min to change to 3.
Avererage below for 10min to go back
trigger:
- platform: time_pattern
minutes: /1
condition:
- condition: not
conditions:
- condition: template
value_template: "{{ states('sensor.CHARGERID_status') == 'disconnected' }}"
action:
- choose:
- conditions:
- condition: state
entity_id: input_select.ev_test_charge
state: Scheduled
sequence:
- service: easee.set_circuit_dynamic_limit
data:
charger_id: CHARGERID
currentP1: "32"
currentP2: "32"
currentP3: "32"
time_to_live: "15"
- conditions:
- condition: state
entity_id: input_select.ev_test_charge
state: Solar 1 Phase
for:
hours: 0
minutes: 10
seconds: 0
- condition: numeric_state
entity_id: sensor.pv_to_ev_power_10m_min
above: 3680
sequence:
- service: input_select.select_option
target:
entity_id: input_select.ev_test_charge
data:
option: Solar 3 Phase
- conditions:
- condition: state
entity_id: input_select.ev_test_charge
state: Solar 3 Phase
for:
hours: 0
minutes: 10
seconds: 0
- condition: numeric_state
entity_id: sensor.pv_to_ev_power_10_min_avg
below: 3680
sequence:
- service: input_select.select_option
target:
entity_id: input_select.ev_test_charge
data:
option: Solar 1 Phase
mode: single
#configuration.yaml
sensor:
- platform: statistics
name: PV to EV Power (10m min)
unique_id: sensor.pv_to_ev_power_10m_min
entity_id: sensor.pv_to_ev_power
state_characteristic: value_min
max_age:
minutes: 10
- platform: statistics
name: PV to EV Power (10 min avg)
unique_id: sensor.pv_to_ev_power_10m_avg
entity_id: sensor.pv_to_ev_power
state_characteristic: average_linear
max_age:
minutes: 10
- platform: statistics
name: PV to EV Power (2 min avg)
unique_id: sensor.pv_to_ev_power_2m_avg
entity_id: sensor.pv_to_ev_power
state_characteristic: average_linear
max_age:
minutes: 2
- platform: statistics
name: N1 Meter Power Netto (10 min avg)
unique_id: sensor.n1_meter_power_netto_avg
entity_id: sensor.n1_meter_power_netto
state_characteristic: average_linear
max_age:
minutes: 10
template:
- sensor:
- name: "PV to EV Power"
unique_id: sensor.pv_to_ev_power
unit_of_measurement: W
device_class: power
state: >
{% set surplus = (0.001 + ((states("sensor.CHARGERID_power") | float(0)) - (states("sensor.n1_meter_power_netto") | float(0))) | round(0) ) %}
{% if surplus < 0.0 %}{% set surplus = 0.0 %}
{% endif %}
{{ surplus }}
@AMajland
Copy link
Author

Ive had to change time to live to 0.

Don't know if it is a change in the HA integration og an easee api change, but it seems that if the values are not changed in HA it will not get trough and go back to default after the minute specified

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