fixes to get rid of startup messages

This commit is contained in:
2026-03-17 06:59:06 +01:00
parent da7239d3c5
commit f1967f24cd
5 changed files with 69 additions and 52 deletions
@@ -1,19 +1,19 @@
- alias: Tesla failsafe charge - alias: Tesla failsafe charge
trigger: trigger:
- platform: time_pattern - platform: template
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')) %}
{% if deadline_ts %}
{% set now_ts = as_timestamp(now()) %} {% set now_ts = as_timestamp(now()) %}
{{ (deadline_ts - now_ts) <= 3600 }} {{ (deadline_ts - now_ts) <= 3600 }}
{% else %}
false
{% endif %}
condition:
- condition: numeric_state - condition: numeric_state
entity_id: sensor.tesla_kwh_needed entity_id: sensor.tesla_kwh_needed
above: 0 above: 0
value_template: "{{ states('sensor.tesla_kwh_needed')|float(0) }}"
action: action:
- service: switch.turn_on - service: switch.turn_on
target: target:
+28 -11
View File
@@ -1,42 +1,59 @@
- alias: Tesla smart charging v3 - alias: Tesla smart charging v3
mode: single id: tesla_smart_charging_v3
mode: restart
trigger: trigger:
- platform: time_pattern - platform: time_pattern
minutes: "/5" minutes: "/5"
condition: condition:
- condition: time # Ensure deadline is valid and in the future
before: input_datetime.tesla_charge_deadline - condition: template
value_template: >
{% set deadline = states('input_datetime.tesla_charge_deadline') %}
{{ deadline not in ['unknown','unavailable',''] and as_timestamp(deadline) > as_timestamp(now()) }}
# Only run when car is connected
- condition: template
value_template: >
{{ states('binary_sensor.tesla_connected') == 'on' }}
action: action:
- choose: - choose:
# -------------------------
# Charge if cheap
# -------------------------
- conditions: - conditions:
- condition: state - condition: template
entity_id: binary_sensor.tesla_charge_now value_template: >
state: "on" {{ states('binary_sensor.tesla_charge_now') == 'on' }}
sequence: sequence:
# Reset hvis session står i connected_finished # Reset charger if stuck in finished state
- choose: - choose:
- conditions: - conditions:
- condition: template - condition: template
value_template: "{{ states('sensor.home_charger_mode') == 'connected_finished' }}" value_template: >
{{ states('sensor.home_charger_mode') == 'connected_finished' }}
sequence: sequence:
- service: switch.turn_off - service: switch.turn_off
target: target:
entity_id: switch.home_charging entity_id: switch.home_charging
- delay: "00:00:05" - delay: "00:00:05"
# Turn charger on
- service: switch.turn_on - service: switch.turn_on
target: target:
entity_id: switch.home_charging entity_id: switch.home_charging
# -------------------------
# Stop charging if not cheap
# -------------------------
- conditions: - conditions:
- condition: state - condition: template
entity_id: binary_sensor.tesla_charge_now value_template: >
state: "off" {{ states('binary_sensor.tesla_charge_now') != 'on' }}
sequence: sequence:
- service: switch.turn_off - service: switch.turn_off
@@ -1,10 +1,10 @@
# template for "Tesla stop when charged"
- alias: Tesla stop when charged - alias: Tesla stop when charged
trigger: trigger:
- platform: template - platform: template
value_template: > value_template: >
{{ (states('sensor.snowywhite_battery') | default(0)) | float >= {{ (states('sensor.snowywhite_battery')|float(0)) >=
(states('number.snowywhite_charge_limit') | default(100)) | float }} (states('number.snowywhite_charge_limit')|float(100)) }}
action: action:
- service: switch.turn_off - service: switch.turn_off
target: target:
+3 -4
View File
@@ -1,16 +1,15 @@
- sensor: - sensor:
- name: tesla_kwh_needed - name: tesla_kwh_needed
unit_of_measurement: "kWh" unit_of_measurement: "kWh"
state: > state: >
{% set capacity = 75 %} {% set capacity = 75 %}
{% set soc = states('sensor.snowywhite_battery')|float %} {% set soc = states('sensor.snowywhite_battery')|float(0) %}
{% set limit = states('number.snowywhite_charge_limit')|float %} {% set limit = states('number.snowywhite_charge_limit')|float(100) %}
{{ ((limit - soc)/100 * capacity)|round(2) }} {{ ((limit - soc)/100 * capacity)|round(2) }}
- name: tesla_charge_hours_needed - name: tesla_charge_hours_needed
unit_of_measurement: "h" unit_of_measurement: "h"
state: > state: >
{% set power = 11 %} {% set power = 11 %}
{% set kwh = states('sensor.tesla_kwh_needed')|float %} {% set kwh = states('sensor.tesla_kwh_needed')|float(0) %}
{{ (kwh / power)|round(2) }} {{ (kwh / power)|round(2) }}
+2 -1
View File
@@ -1,4 +1,4 @@
binary_sensor: - binary_sensor:
- name: tesla_charge_now - name: tesla_charge_now
state: > state: >
{% set deadline_raw = states('input_datetime.tesla_charge_deadline') %} {% set deadline_raw = states('input_datetime.tesla_charge_deadline') %}
@@ -27,3 +27,4 @@ binary_sensor:
{% set now_slot = now().replace(minute=0, second=0, microsecond=0).isoformat() %} {% set now_slot = now().replace(minute=0, second=0, microsecond=0).isoformat() %}
{{ cheapest | selectattr('hour','equalto',now_slot) | list | count > 0 }} {{ cheapest | selectattr('hour','equalto',now_slot) | list | count > 0 }}