From 5a9db0b8c2923b66ad1f6cb57f0e66abed1dbe71 Mon Sep 17 00:00:00 2001 From: Claus Dethlefsen Date: Tue, 17 Mar 2026 06:18:50 +0100 Subject: [PATCH] improve(automation): increase reliability of tesla charging control - Change mode to restart to prevent skipped runs - Replace failsafe template trigger with time_pattern - Add plugged-in condition to avoid unnecessary switching - Add explicit deadline validation condition Result: - More reliable execution of charging logic - Prevents missed failsafe activation - Reduces unnecessary charger toggling --- include/automations/tesla_charge_failsafe.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/automations/tesla_charge_failsafe.yaml b/include/automations/tesla_charge_failsafe.yaml index fdeb39d..7e71e44 100644 --- a/include/automations/tesla_charge_failsafe.yaml +++ b/include/automations/tesla_charge_failsafe.yaml @@ -1,12 +1,15 @@ - alias: Tesla failsafe charge trigger: - - platform: template + - platform: time_pattern + minutes: "/5" + + condition: + - condition: template value_template: > {% set deadline_ts = as_timestamp(states('input_datetime.tesla_charge_deadline')) %} {% set now_ts = as_timestamp(now()) %} - {{ (deadline_ts - now_ts) <= 3600 }} # 1 time = 3600 sekunder + {{ (deadline_ts - now_ts) <= 3600 }} - condition: - condition: numeric_state entity_id: sensor.tesla_kwh_needed above: 0 @@ -14,4 +17,4 @@ action: - service: switch.turn_on target: - entity_id: switch.home_charging \ No newline at end of file + entity_id: switch.home_charging