From 8fa4db9d89d9ffcc3e69df98c3b5290e783eef9d Mon Sep 17 00:00:00 2001 From: Claus Dethlefsen Date: Mon, 16 Mar 2026 18:16:19 +0100 Subject: [PATCH] fix: add platform to tesla_smart_charge binary sensor and move to templates directory --- configuration.yaml | 6 ------ include/automations/tesla_charge_failsafe.yaml | 17 +++++++++++++++++ include/automations/tesla_stop_when_full.yaml | 3 +-- include/input/datetime/tesla.yaml | 5 +++++ .../tesla_smart_charge.yaml | 2 ++ 5 files changed, 25 insertions(+), 8 deletions(-) rename include/{binary_sensors => templates}/tesla_smart_charge.yaml (97%) diff --git a/configuration.yaml b/configuration.yaml index 8cbec9c..24c7f6b 100755 --- a/configuration.yaml +++ b/configuration.yaml @@ -77,12 +77,6 @@ python_script: frontend: themes: !include_dir_merge_named include/themes/ -logger: - default: warning - logs: - custom_components.affalddk: debug - pyaffalddk: debug - ################################################## # Integrations ################################################## diff --git a/include/automations/tesla_charge_failsafe.yaml b/include/automations/tesla_charge_failsafe.yaml index e69de29..fdeb39d 100644 --- a/include/automations/tesla_charge_failsafe.yaml +++ b/include/automations/tesla_charge_failsafe.yaml @@ -0,0 +1,17 @@ +- alias: Tesla failsafe charge + trigger: + - platform: 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 + + condition: + - condition: numeric_state + entity_id: sensor.tesla_kwh_needed + above: 0 + + action: + - service: switch.turn_on + target: + entity_id: switch.home_charging \ No newline at end of file diff --git a/include/automations/tesla_stop_when_full.yaml b/include/automations/tesla_stop_when_full.yaml index 463c04a..2758382 100644 --- a/include/automations/tesla_stop_when_full.yaml +++ b/include/automations/tesla_stop_when_full.yaml @@ -8,5 +8,4 @@ action: - service: switch.turn_off target: - entity_id: switch.home_charging - \ No newline at end of file + entity_id: switch.home_charging \ No newline at end of file diff --git a/include/input/datetime/tesla.yaml b/include/input/datetime/tesla.yaml index e69de29..e821e34 100644 --- a/include/input/datetime/tesla.yaml +++ b/include/input/datetime/tesla.yaml @@ -0,0 +1,5 @@ +tesla_charge_deadline: + name: Tesla charge deadline + has_date: true + has_time: true + \ No newline at end of file diff --git a/include/binary_sensors/tesla_smart_charge.yaml b/include/templates/tesla_smart_charge.yaml similarity index 97% rename from include/binary_sensors/tesla_smart_charge.yaml rename to include/templates/tesla_smart_charge.yaml index bc1ee3a..c62d9d4 100644 --- a/include/binary_sensors/tesla_smart_charge.yaml +++ b/include/templates/tesla_smart_charge.yaml @@ -1,3 +1,5 @@ +platform: template +sensors: - name: tesla_charge_now state: > {% set deadline = states('input_datetime.tesla_charge_deadline') %}