Nu virker det
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
- alias: Tesla smart charging v3
|
||||
id: tesla_smart_charging_v3
|
||||
- alias: Tesla smart charging v4
|
||||
id: tesla_smart_charging_v4
|
||||
mode: restart
|
||||
|
||||
trigger:
|
||||
@@ -7,55 +7,65 @@
|
||||
minutes: "/5"
|
||||
|
||||
condition:
|
||||
# Ensure deadline is valid and in the future
|
||||
# Valid future 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()) }}
|
||||
{{ 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' }}
|
||||
# Car must be connected
|
||||
- condition: state
|
||||
entity_id: binary_sensor.snowywhite_charger
|
||||
state: "on"
|
||||
|
||||
action:
|
||||
- variables:
|
||||
charge_now: "{{ is_state('binary_sensor.tesla_charge_now', 'on') }}"
|
||||
charger_on: "{{ is_state('switch.home_charging', 'on') }}"
|
||||
|
||||
- choose:
|
||||
|
||||
# -------------------------
|
||||
# Charge if cheap
|
||||
# START charging (cheap hour)
|
||||
# -------------------------
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ states('binary_sensor.tesla_charge_now') == 'on' }}
|
||||
value_template: "{{ charge_now and not charger_on }}"
|
||||
|
||||
sequence:
|
||||
# Reset charger if stuck in finished state
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ states('sensor.home_charger_mode') == 'connected_finished' }}
|
||||
sequence:
|
||||
- service: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.home_charging
|
||||
- delay: "00:00:05"
|
||||
- service: system_log.write
|
||||
data:
|
||||
message: "Tesla: START charging (cheap hour)"
|
||||
level: info
|
||||
|
||||
# Turn charger on
|
||||
- service: switch.turn_on
|
||||
target:
|
||||
entity_id: switch.home_charging
|
||||
|
||||
# -------------------------
|
||||
# Stop charging if not cheap
|
||||
# STOP charging (not cheap)
|
||||
# -------------------------
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ states('binary_sensor.tesla_charge_now') != 'on' }}
|
||||
value_template: "{{ not charge_now and charger_on }}"
|
||||
|
||||
sequence:
|
||||
- service: system_log.write
|
||||
data:
|
||||
message: "Tesla: STOP charging (not cheap)"
|
||||
level: info
|
||||
|
||||
- service: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.home_charging
|
||||
|
||||
# -------------------------
|
||||
# Default: do nothing
|
||||
# -------------------------
|
||||
- service: system_log.write
|
||||
data:
|
||||
message: >
|
||||
Tesla: No action (charge_now={{ charge_now }},
|
||||
charger_on={{ charger_on }})
|
||||
level: debug
|
||||
|
||||
Reference in New Issue
Block a user