EVcharge_PRO: WIP1
This commit is contained in:
@@ -226,4 +226,7 @@
|
|||||||
evcharge_entity2: switch.evcharge_back
|
evcharge_entity2: switch.evcharge_back
|
||||||
use_entity1: input_boolean.evcharge_front_request
|
use_entity1: input_boolean.evcharge_front_request
|
||||||
use_entity2: input_boolean.evcharge_back_request
|
use_entity2: input_boolean.evcharge_back_request
|
||||||
start_button: input_button.evcharge_start
|
start_button: input_button.evcharge_pro_start
|
||||||
|
charged_entity1: input_number.evcharge_front_charged
|
||||||
|
charged_entity2: input_number.evcharge_back_charged
|
||||||
|
stop_button: input_button.evcharge_pro_stop
|
||||||
|
|||||||
311
blueprints/automation/homeassistant/evcharge_process_pro.yaml
Normal file
311
blueprints/automation/homeassistant/evcharge_process_pro.yaml
Normal file
@@ -0,0 +1,311 @@
|
|||||||
|
blueprint:
|
||||||
|
name: evcharge_process_pro
|
||||||
|
description: Manage charging process between two charging points with Charged Energy calculation
|
||||||
|
domain: automation
|
||||||
|
author: Tiziano Trabattoni
|
||||||
|
input:
|
||||||
|
evcharge_entity1:
|
||||||
|
name: Charge via 'Controlled Plug1'
|
||||||
|
description: Identifies the Switch1 (eg EVcharge-front)
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
filter:
|
||||||
|
- domain: switch
|
||||||
|
evcharge_entity2:
|
||||||
|
name: Charge via 'Controlled Plug2'
|
||||||
|
description: Identifies the Switch2 (eg EVcharge-back)
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
filter:
|
||||||
|
- domain: switch
|
||||||
|
use_entity1:
|
||||||
|
name: Enable charge via 'Controlled Plug1'
|
||||||
|
description: Identifies the input flag for charging on 'Controlled Plug1' (eg EVcharge_front_request)
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
filter:
|
||||||
|
- domain: input_boolean
|
||||||
|
use_entity2:
|
||||||
|
name: Enable charge via 'Controlled Plug2'
|
||||||
|
description: Identifies the input flag for charging on 'Controlled Plug2' (eg EVcharge_back_request)
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
filter:
|
||||||
|
- domain: input_boolean
|
||||||
|
charged_entity1:
|
||||||
|
name: Shows energy charged through 'Controlled Plug1'
|
||||||
|
description: Identifies the card showing energy charged by 'Controlled Plug1'
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
filter:
|
||||||
|
- domain: input_number
|
||||||
|
charged_entity2:
|
||||||
|
name: Shows energy charged through 'Controlled Plug2'
|
||||||
|
description: Identifies the card showing energy charged by 'Controlled Plug2' (eg EVcharge_back_request)
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
filter:
|
||||||
|
- domain: input_number
|
||||||
|
start_button:
|
||||||
|
name: start_button
|
||||||
|
description: Identifies the button to start EVcharge process
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
filter:
|
||||||
|
- domain: input_button
|
||||||
|
stop_button:
|
||||||
|
name: stop_button
|
||||||
|
description: Identifies the button to stop EVcharge process
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
filter:
|
||||||
|
- domain: input_button
|
||||||
|
triggers:
|
||||||
|
- trigger: state # Want to trigger start now
|
||||||
|
entity_id: !input start_button
|
||||||
|
id: start_now
|
||||||
|
# - trigger: state # Want to trigger stop now
|
||||||
|
# entity_id: !input stop_button
|
||||||
|
# id: stop_now
|
||||||
|
- trigger: time # Start at F3 start tome
|
||||||
|
at: input_datetime.evcharge_good_time_start
|
||||||
|
id: start_at_good_time
|
||||||
|
|
||||||
|
# for time being let's do sequential charge for Plug1 and then Plug2
|
||||||
|
mode: single
|
||||||
|
|
||||||
|
# here we could stop immediately if sensor.pw_load_power is above 5000W but lets decide after
|
||||||
|
conditions: []
|
||||||
|
|
||||||
|
variables:
|
||||||
|
evcharge_entity1_var: !input evcharge_entity1
|
||||||
|
evcharge_entity2_var: !input evcharge_entity2
|
||||||
|
|
||||||
|
evcharge_entity1_power_var: >-
|
||||||
|
{% from 'template_library.jinja' import getpower_id %}
|
||||||
|
{{ getpower_id(evcharge_entity1_var) }}
|
||||||
|
evcharge_entity2_power_var: >-
|
||||||
|
{% from 'template_library.jinja' import getpower_id %}
|
||||||
|
{{ getpower_id(evcharge_entity2_var) }}
|
||||||
|
evcharge_entity1_energy_var: >-
|
||||||
|
{% from 'template_library.jinja' import getenergy_id %}
|
||||||
|
{{ getenergy_id(evcharge_entity1_var) }}
|
||||||
|
evcharge_entity2_energy_var: >-
|
||||||
|
{% from 'template_library.jinja' import getenergy_id %}
|
||||||
|
{{ getenergy_id(evcharge_entity2_var) }}
|
||||||
|
|
||||||
|
use_entity1_var: !input use_entity1
|
||||||
|
use_entity2_var: !input use_entity2
|
||||||
|
|
||||||
|
# here list of mobile APP to be notified
|
||||||
|
recipient_list_notification:
|
||||||
|
- notify.mobile_app_tiziano_iphone15pro
|
||||||
|
- notify.mobile_app_emanuele_s24
|
||||||
|
|
||||||
|
recipient_list_gmail:
|
||||||
|
title: "EVcharge Process"
|
||||||
|
target:
|
||||||
|
- "tiziano.trabattoni@gmail.com"
|
||||||
|
#- "ema.trabattoni@gmail.com"
|
||||||
|
|
||||||
|
actions:
|
||||||
|
#
|
||||||
|
- if:
|
||||||
|
- or:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ is_state(evcharge_entity1_var, 'on') }}"
|
||||||
|
# value_template: "{{ false }}" # TEST ONLY
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ is_state(evcharge_entity2_var, 'on') }}"
|
||||||
|
# value_template: "{{ false }}" # TEST ONLY
|
||||||
|
|
||||||
|
then:
|
||||||
|
# charge already active, send message email and terminate
|
||||||
|
sequence:
|
||||||
|
- repeat:
|
||||||
|
for_each: "{{ recipient_list_notification }}"
|
||||||
|
sequence:
|
||||||
|
- action: "{{ repeat.item }}"
|
||||||
|
metadata: {}
|
||||||
|
data:
|
||||||
|
message: >-
|
||||||
|
"EVcharge process is ALREADY RUNNING"
|
||||||
|
title: "EV Charge process ERROR"
|
||||||
|
|
||||||
|
else:
|
||||||
|
# EVcharge can continue
|
||||||
|
sequence:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ is_state(use_entity1_var, 'on') }}"
|
||||||
|
then: # EVcharge entity_1 (eg front) charge is requested
|
||||||
|
sequence:
|
||||||
|
- repeat: # send message to all recipient-list members
|
||||||
|
for_each: "{{ recipient_list_notification }}"
|
||||||
|
sequence:
|
||||||
|
- action: "{{ repeat.item }}"
|
||||||
|
metadata: {}
|
||||||
|
data:
|
||||||
|
message: >-
|
||||||
|
"EVcharge process on {{ evcharge_entity1_var }} has started"
|
||||||
|
title: EV Charge process
|
||||||
|
- action: notify.tiziano_trabattoni_gmail_com
|
||||||
|
data:
|
||||||
|
title: "EVcharge process on {{ evcharge_entity1_var }} has started"
|
||||||
|
target: "{{ recipient_list_gmail['target'] }}"
|
||||||
|
message: >-
|
||||||
|
"EVcharge process on {{ evcharge_entity1_var }} has started"
|
||||||
|
|
||||||
|
# take energy counter before charging
|
||||||
|
- variables:
|
||||||
|
energy1_before: "{{ states(evcharge_entity1_energy_var) | float | round(2) }}"
|
||||||
|
|
||||||
|
# Start plug1 and wait until power measured is below input_number.evcharge_no_charge_threshold for 10 minutes = 600 seconds
|
||||||
|
- action: switch.turn_on
|
||||||
|
# automation.apri_cancellettoentity_id: !input evcharge_entity1
|
||||||
|
entity_id: switch.presa_smart_1 # TEST ONLY
|
||||||
|
|
||||||
|
# need to wait car to start charging
|
||||||
|
# - delay: 120
|
||||||
|
- delay: 10 # TEST ONLY
|
||||||
|
|
||||||
|
# Wait for charging to complete
|
||||||
|
- repeat:
|
||||||
|
until:
|
||||||
|
- condition: and
|
||||||
|
conditions:
|
||||||
|
- "{{ ( states('input_number.test_evcharge_front') | int) < (states('input_number.evcharge_no_charge_threshold') | int) }}" # TEST ONLY
|
||||||
|
# - "{{ ( states(evcharge_entity1_power_var) | int ) < ( states('input_number.evcharge_no_charge_threshold') | int ) }}"
|
||||||
|
- "{{ isstate('input_boolean.let_run')}}"
|
||||||
|
|
||||||
|
sequence:
|
||||||
|
- variables:
|
||||||
|
energy1_while_var: >-
|
||||||
|
{% from 'template_library.jinja' import getenergy_id %}
|
||||||
|
{{ getenergy_id(evcharge_entity1_var) }}
|
||||||
|
energy1_while: "{{ states(energy1_while_var ) }}"
|
||||||
|
evcharge_entity1_energy_charged: "{{ ((energy1_while | float| round(2)) - energy1_before )| float | round(2) }}"
|
||||||
|
|
||||||
|
# - delay: 120
|
||||||
|
- delay: 10 # TEST ONLY
|
||||||
|
|
||||||
|
# take energy counter after charging
|
||||||
|
- variables:
|
||||||
|
energy1_after: "{{ states(evcharge_entity1_energy_var) | float | round(2) }}"
|
||||||
|
|
||||||
|
# turn off evcharge_entity1
|
||||||
|
- action: switch.turn_off
|
||||||
|
# entity_id: !input evcharge_entity1
|
||||||
|
entity_id: switch.presa_smart_1 # TEST ONLY
|
||||||
|
- delay: 10
|
||||||
|
- action: switch.turn_off
|
||||||
|
# entity_id: !input evcharge_entity1
|
||||||
|
entity_id: switch.presa_smart_1 # TEST ONLY
|
||||||
|
|
||||||
|
- repeat: # send message to all recipient-list members
|
||||||
|
for_each: "{{ recipient_list_notification }}"
|
||||||
|
sequence:
|
||||||
|
- action: "{{ repeat.item }}"
|
||||||
|
metadata: {}
|
||||||
|
data:
|
||||||
|
message: >-
|
||||||
|
"EVcharge process on {{ evcharge_entity1_var }} has ended: {{ ( energy1_after - energy1_before ) | round(2) }} kW/h charged"
|
||||||
|
title: EV Charge process
|
||||||
|
|
||||||
|
- action: notify.tiziano_trabattoni_gmail_com
|
||||||
|
data:
|
||||||
|
title: "EVcharge process on {{ evcharge_entity1_var }} has ended: {{ ( energy1_after - energy1_before ) | round(2) }} kW/h charged"
|
||||||
|
target: "{{ recipient_list_gmail['target'] }}"
|
||||||
|
message: >-
|
||||||
|
"EVcharge process on {{ evcharge_entity1_var }} has ended: {{ ( energy1_after - energy1_before ) | round(2) }} kW/h charged"
|
||||||
|
|
||||||
|
# wait couple of minutes before starting charge on plug2
|
||||||
|
# - delay: 120
|
||||||
|
- delay: 10 # TEST ONLY
|
||||||
|
# - if:
|
||||||
|
# - condition: template
|
||||||
|
# value_template: "{{ is_state(use_entity2_var, 'on') }}"
|
||||||
|
# then:
|
||||||
|
# sequence:
|
||||||
|
# # then start plug2 and wait until power measured is below input_number.evcharge_no_charge_threshold for 10 minutes = 600 seconds
|
||||||
|
# - repeat: # send message to all recipient-list members
|
||||||
|
# for_each: "{{ recipient_list_notification }}"
|
||||||
|
# sequence:
|
||||||
|
# - action: "{{ repeat.item }}"
|
||||||
|
# metadata: {}
|
||||||
|
# data:
|
||||||
|
# message: >-
|
||||||
|
# "EVcharge process on {{ evcharge_entity2_var }} has started"
|
||||||
|
# title: EV Charge process
|
||||||
|
# - action: notify.tiziano_trabattoni_gmail_com
|
||||||
|
# data:
|
||||||
|
# title: "EVcharge process on {{ evcharge_entity2_var }} has started"
|
||||||
|
# target: "{{ recipient_list_gmail['target'] }}"
|
||||||
|
# message: >-
|
||||||
|
# "EVcharge process on {{ evcharge_entity2_var }} has started"
|
||||||
|
#
|
||||||
|
# # take energy counter before charging
|
||||||
|
# - variables:
|
||||||
|
# energy2_before: "{{ states(evcharge_entity2_energy_var) | float | round(2) }}"
|
||||||
|
#
|
||||||
|
# # turn_on evcharge_entity2
|
||||||
|
# - action: switch.turn_on
|
||||||
|
# entity_id: !input evcharge_entity2
|
||||||
|
# # entity_id: switch.presa_smart_2 # TEST ONLY
|
||||||
|
#
|
||||||
|
# # need to wait car to start charging
|
||||||
|
# - delay: 120
|
||||||
|
# # - delay: 10 # TEST ONLY
|
||||||
|
#
|
||||||
|
# # Wait for charging to complete
|
||||||
|
# - repeat:
|
||||||
|
# until: "{{ ( states(evcharge_entity2_power_var) | int ) < ( states('input_number.evcharge_no_charge_threshold') | int) }}"
|
||||||
|
# # until: "{{ ( states('input_number.test_evcharge_back') | int) < ( states('input_number.evcharge_no_charge_threshold') | int) }}" # TEST ONLY
|
||||||
|
# sequence:
|
||||||
|
# - delay: 120
|
||||||
|
# # - delay: 10 # TEST ONLY
|
||||||
|
#
|
||||||
|
# # take energy counter after charging
|
||||||
|
# - variables:
|
||||||
|
# energy2_after: "{{ states(evcharge_entity2_energy_var) | float | round(2) }}"
|
||||||
|
#
|
||||||
|
# # turn off evcharge_entity2
|
||||||
|
# - action: switch.turn_off
|
||||||
|
# entity_id: !input evcharge_entity2
|
||||||
|
# # entity_id: switch.presa_smart_2 # TEST ONLY
|
||||||
|
# - delay: 10
|
||||||
|
# - action: switch.turn_off
|
||||||
|
# entity_id: !input evcharge_entity2
|
||||||
|
#
|
||||||
|
# - repeat: # send message to all recipient-list members
|
||||||
|
# for_each: "{{ recipient_list_notification }}"
|
||||||
|
# sequence:
|
||||||
|
# - action: "{{ repeat.item }}"
|
||||||
|
# metadata: {}
|
||||||
|
# data:
|
||||||
|
# message: >-
|
||||||
|
# "EVcharge process on {{ evcharge_entity2_var }} has ended: {{ ( energy2_after - energy2_before ) | round(2) }} kW/h charged"
|
||||||
|
# title: EV Charge process
|
||||||
|
# - action: notify.tiziano_trabattoni_gmail_com
|
||||||
|
# data:
|
||||||
|
# title: "EVcharge process on {{ evcharge_entity2_var }} has ended: {{ ( energy2_after - energy2_before ) | round(2) }} kW/h charged"
|
||||||
|
# target: "{{ recipient_list_gmail['target'] }}"
|
||||||
|
# message: >-
|
||||||
|
# "EVcharge process on {{ evcharge_entity2_var }} has ended: {{ ( energy2_after - energy2_before ) | round(2) }} kW/h charged"
|
||||||
|
- if:
|
||||||
|
- and:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ is_state(use_entity1_var, 'off') }}"
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ is_state(use_entity2_var, 'off') }}"
|
||||||
|
then:
|
||||||
|
- repeat: # send message to all recipient-list members
|
||||||
|
for_each: "{{ recipient_list }}"
|
||||||
|
|
||||||
|
sequence:
|
||||||
|
- action: "{{ repeat.item }}"
|
||||||
|
metadata: {}
|
||||||
|
data:
|
||||||
|
message: >-
|
||||||
|
"EVcharge process activation ERROR, select what to charge"
|
||||||
|
title: EV Charge process ERROR
|
||||||
@@ -1,27 +1,27 @@
|
|||||||
{# This macro returns _power entity for a controlled plug device #}
|
{# This macro returns _power entity for a controlled plug device #}
|
||||||
{% macro getpower_id(evcharge_id) %}
|
{% macro getpower_id(evcharge_id) %}
|
||||||
{% set attrib_list = device_entities( device_id (evcharge_id ) ) %}
|
{% set attrib_list = device_entities( device_id (evcharge_id ) ) %}
|
||||||
|
|
||||||
{% for attrib in attrib_list -%}
|
{% for attrib in attrib_list -%}
|
||||||
{% if ( attrib | regex_search('power$')) -%}
|
{% if ( attrib | regex_search('power$')) -%}
|
||||||
{{ attrib }}
|
{{ attrib }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{########################################################################}
|
{########################################################################}
|
||||||
|
|
||||||
{# This macro returns _energy entity for a controlled plug device #}
|
{# This macro returns _energy entity for a controlled plug device #}
|
||||||
|
|
||||||
{% macro getenergy_id(evcharge_id) %}
|
{% macro getenergy_id(evcharge_id) %}
|
||||||
{% set attrib_list = device_entities( device_id (evcharge_id ) ) %}
|
{% set attrib_list = device_entities( device_id (evcharge_id ) ) %}
|
||||||
|
|
||||||
{% for attrib in attrib_list -%}
|
{% for attrib in attrib_list -%}
|
||||||
{% if ( attrib | regex_search('energy$')) -%}
|
{% if ( attrib | regex_search('energy$')) -%}
|
||||||
{{ attrib }}
|
{{ attrib }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user