various tidyups
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
# packages/16a_ev_charging_controls.yaml
|
||||
#
|
||||
# VERSION:
|
||||
# V1.4 2026-08-12
|
||||
# - Consolidated Leaf 16A and 32A session energy tracking in this package.
|
||||
#
|
||||
# V1.3 2026-07-24
|
||||
# - Added startup catch-up to offpeak_end: when HA starts outside the
|
||||
# offpeak window in Normal mode, the relay is turned off immediately.
|
||||
@@ -27,7 +30,8 @@
|
||||
#
|
||||
# PURPOSE:
|
||||
# Controls the Leaf 16A charger relay using scheduled offpeak operation and
|
||||
# user-selectable immediate or charge-until-full modes.
|
||||
# user-selectable immediate or charge-until-full modes. Tracks completed
|
||||
# Leaf charging sessions across both the 16A and 32A chargers.
|
||||
#
|
||||
# DEPENDENCIES:
|
||||
# - switch.garage_db_control_16a_wallcharger_operation controls charger power.
|
||||
@@ -450,3 +454,171 @@ automation:
|
||||
entity_id: input_select.ev_16a_charge_mode
|
||||
data:
|
||||
option: "Normal (Offpeak)"
|
||||
|
||||
#############################################################################
|
||||
# SESSION ENERGY TRACKING
|
||||
#############################################################################
|
||||
|
||||
- id: leaf_ev_charger_track_session_energy
|
||||
alias: "Leaf EV Charger - Track Session Energy"
|
||||
description: >-
|
||||
Store the energy used by the most recently completed Leaf charge session
|
||||
on either charger.
|
||||
mode: queued
|
||||
max: 2
|
||||
|
||||
triggers:
|
||||
- trigger: homeassistant
|
||||
event: start
|
||||
id: ha_start
|
||||
- trigger: state
|
||||
entity_id: binary_sensor.garage_db_control_16a_wallcharger_charging
|
||||
to: "on"
|
||||
id: start_16a
|
||||
- trigger: state
|
||||
entity_id: binary_sensor.garage_db_control_16a_wallcharger_charging
|
||||
from: "on"
|
||||
to: "off"
|
||||
id: stop_16a
|
||||
- trigger: state
|
||||
entity_id: binary_sensor.leaf_charging
|
||||
to: "on"
|
||||
id: start_32a
|
||||
- trigger: state
|
||||
entity_id: binary_sensor.main_house_3_phase_power_monitor_32a_wallcharger_charging
|
||||
to: "off"
|
||||
id: stop_32a
|
||||
- trigger: state
|
||||
entity_id: binary_sensor.atto_3_charging
|
||||
to: "on"
|
||||
id: cancel_32a
|
||||
|
||||
conditions: []
|
||||
|
||||
actions:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: ha_start
|
||||
- condition: state
|
||||
entity_id: binary_sensor.garage_db_control_16a_wallcharger_charging
|
||||
state: "on"
|
||||
sequence:
|
||||
- action: input_number.set_value
|
||||
target:
|
||||
entity_id: input_number.leaf_charge_session_start_energy
|
||||
data:
|
||||
value: "{{ states('sensor.garage_db_control_16a_wallcharger_total_energy') | float(0) }}"
|
||||
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: ha_start
|
||||
- condition: state
|
||||
entity_id: binary_sensor.main_house_3_phase_power_monitor_32a_wallcharger_charging
|
||||
state: "on"
|
||||
- condition: state
|
||||
entity_id: binary_sensor.atto_3_charging
|
||||
state: "off"
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ has_value('sensor.main_house_3_phase_power_monitor_32a_wallcharger_total_energy') }}
|
||||
sequence:
|
||||
- action: input_number.set_value
|
||||
target:
|
||||
entity_id: input_number.leaf_32a_charge_session_start_energy
|
||||
data:
|
||||
value: "{{ states('sensor.main_house_3_phase_power_monitor_32a_wallcharger_total_energy') | float(0) }}"
|
||||
- action: input_boolean.turn_on
|
||||
target:
|
||||
entity_id: input_boolean.leaf_32a_charge_session_active
|
||||
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: start_16a
|
||||
sequence:
|
||||
- action: input_number.set_value
|
||||
target:
|
||||
entity_id: input_number.leaf_charge_session_start_energy
|
||||
data:
|
||||
value: "{{ states('sensor.garage_db_control_16a_wallcharger_total_energy') | float(0) }}"
|
||||
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: stop_16a
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ states('sensor.garage_db_control_16a_wallcharger_total_energy') | float(0)
|
||||
>= states('input_number.leaf_charge_session_start_energy') | float(0) }}
|
||||
sequence:
|
||||
- action: input_number.set_value
|
||||
target:
|
||||
entity_id: input_number.leaf_last_session_energy
|
||||
data:
|
||||
value: >-
|
||||
{{ (states('sensor.garage_db_control_16a_wallcharger_total_energy') | float(0)
|
||||
- states('input_number.leaf_charge_session_start_energy') | float(0)) | round(3) }}
|
||||
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: start_32a
|
||||
- condition: state
|
||||
entity_id: binary_sensor.main_house_3_phase_power_monitor_32a_wallcharger_charging
|
||||
state: "on"
|
||||
- condition: state
|
||||
entity_id: binary_sensor.atto_3_charging
|
||||
state: "off"
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ has_value('sensor.main_house_3_phase_power_monitor_32a_wallcharger_total_energy') }}
|
||||
sequence:
|
||||
- action: input_number.set_value
|
||||
target:
|
||||
entity_id: input_number.leaf_32a_charge_session_start_energy
|
||||
data:
|
||||
value: "{{ states('sensor.main_house_3_phase_power_monitor_32a_wallcharger_total_energy') | float(0) }}"
|
||||
- action: input_boolean.turn_on
|
||||
target:
|
||||
entity_id: input_boolean.leaf_32a_charge_session_active
|
||||
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: stop_32a
|
||||
- condition: state
|
||||
entity_id: input_boolean.leaf_32a_charge_session_active
|
||||
state: "on"
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{
|
||||
has_value('sensor.main_house_3_phase_power_monitor_32a_wallcharger_total_energy')
|
||||
and states('sensor.main_house_3_phase_power_monitor_32a_wallcharger_total_energy') | float(0)
|
||||
>= states('input_number.leaf_32a_charge_session_start_energy') | float(0)
|
||||
}}
|
||||
sequence:
|
||||
- action: input_number.set_value
|
||||
target:
|
||||
entity_id: input_number.leaf_last_session_energy
|
||||
data:
|
||||
value: >-
|
||||
{{
|
||||
(
|
||||
states('sensor.main_house_3_phase_power_monitor_32a_wallcharger_total_energy') | float(0)
|
||||
- states('input_number.leaf_32a_charge_session_start_energy') | float(0)
|
||||
) | round(3)
|
||||
}}
|
||||
- action: input_boolean.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.leaf_32a_charge_session_active
|
||||
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: cancel_32a
|
||||
- condition: state
|
||||
entity_id: input_boolean.leaf_32a_charge_session_active
|
||||
state: "on"
|
||||
sequence:
|
||||
- action: input_boolean.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.leaf_32a_charge_session_active
|
||||
|
||||
Reference in New Issue
Block a user