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
This commit is contained in:
2026-03-17 06:18:50 +01:00
parent dde5ff292a
commit 5a9db0b8c2
@@ -1,12 +1,15 @@
- alias: Tesla failsafe charge - alias: Tesla failsafe charge
trigger: trigger:
- platform: template - platform: time_pattern
minutes: "/5"
condition:
- condition: template
value_template: > value_template: >
{% set deadline_ts = as_timestamp(states('input_datetime.tesla_charge_deadline')) %} {% set deadline_ts = as_timestamp(states('input_datetime.tesla_charge_deadline')) %}
{% set now_ts = as_timestamp(now()) %} {% set now_ts = as_timestamp(now()) %}
{{ (deadline_ts - now_ts) <= 3600 }} # 1 time = 3600 sekunder {{ (deadline_ts - now_ts) <= 3600 }}
condition:
- condition: numeric_state - condition: numeric_state
entity_id: sensor.tesla_kwh_needed entity_id: sensor.tesla_kwh_needed
above: 0 above: 0
@@ -14,4 +17,4 @@
action: action:
- service: switch.turn_on - service: switch.turn_on
target: target:
entity_id: switch.home_charging entity_id: switch.home_charging