Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f261ee8d2 | |||
| f1967f24cd |
@@ -1,68 +1,61 @@
|
||||
- id: '1691939802290'
|
||||
alias: Åbn garage ved tryk på 1
|
||||
description: ''
|
||||
- id: hue_switch_garage_and_lights
|
||||
alias: Hue switch - garage og lys
|
||||
mode: restart
|
||||
|
||||
trigger:
|
||||
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
|
||||
domain: hue
|
||||
platform: device
|
||||
type: initial_press
|
||||
subtype: 1
|
||||
unique_id: 4b8a056e-973f-48cf-8a19-3586f6b05dcf
|
||||
condition: []
|
||||
action:
|
||||
- device_id: 3bc3eab99b46dae3e469bfa4060ce0f5
|
||||
domain: cover
|
||||
entity_id: 4bd9c13b7bb0cc3245e38211ded2be92
|
||||
type: open
|
||||
mode: single
|
||||
- id: '1691941083623'
|
||||
alias: Sluk alt lys ved tryk på 0
|
||||
description: ''
|
||||
trigger:
|
||||
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
|
||||
domain: hue
|
||||
platform: device
|
||||
type: initial_press
|
||||
subtype: 4
|
||||
unique_id: f97d54a1-2283-4fb0-8709-b873a310732b
|
||||
condition: []
|
||||
- platform: event
|
||||
event_type: hue_event
|
||||
event_data:
|
||||
id: 5f6b41e54f3226acd9c9ab54a3acb527
|
||||
|
||||
action:
|
||||
- choose:
|
||||
|
||||
# --- GARAGE ---
|
||||
|
||||
# Kort tryk på knap 1 → Åbn garage
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ trigger.event.data.type == 'initial_press'
|
||||
and trigger.event.data.subtype == 1 }}
|
||||
sequence:
|
||||
- service: cover.open_cover
|
||||
target:
|
||||
entity_id: cover.anne
|
||||
|
||||
# Langt tryk på knap 1 → Luk garage
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ trigger.event.data.type == 'long_press'
|
||||
and trigger.event.data.subtype == 1 }}
|
||||
sequence:
|
||||
- service: cover.close_cover
|
||||
target:
|
||||
entity_id: cover.anne
|
||||
|
||||
|
||||
# --- LYS ---
|
||||
|
||||
# Kort tryk på knap 4 → Sluk alt lys
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ trigger.event.data.type == 'initial_press'
|
||||
and trigger.event.data.subtype == 4 }}
|
||||
sequence:
|
||||
- service: light.turn_off
|
||||
data: {}
|
||||
target:
|
||||
entity_id: light.alle_lys
|
||||
mode: single
|
||||
- id: '1691941222856'
|
||||
alias: Tænd alt lyset ved langt tryk på 0
|
||||
description: ''
|
||||
trigger:
|
||||
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
|
||||
domain: hue
|
||||
platform: device
|
||||
type: long_press
|
||||
subtype: 4
|
||||
unique_id: f97d54a1-2283-4fb0-8709-b873a310732b
|
||||
condition: []
|
||||
action:
|
||||
|
||||
# Langt tryk på knap 4 → Tænd alt lys
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ trigger.event.data.type == 'long_press'
|
||||
and trigger.event.data.subtype == 4 }}
|
||||
sequence:
|
||||
- service: light.turn_on
|
||||
data: {}
|
||||
target:
|
||||
entity_id: light.alle_lys
|
||||
mode: single
|
||||
- id: '1692023138692'
|
||||
alias: Luk garage ved langt tryk på '1'
|
||||
description: ''
|
||||
trigger:
|
||||
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
|
||||
domain: hue
|
||||
platform: device
|
||||
type: long_press
|
||||
subtype: 1
|
||||
unique_id: 4b8a056e-973f-48cf-8a19-3586f6b05dcf
|
||||
condition: []
|
||||
action:
|
||||
- device_id: 3bc3eab99b46dae3e469bfa4060ce0f5
|
||||
domain: cover
|
||||
entity_id: 4bd9c13b7bb0cc3245e38211ded2be92
|
||||
type: close
|
||||
mode: single
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
- alias: Tesla failsafe charge
|
||||
trigger:
|
||||
- platform: time_pattern
|
||||
minutes: "/5"
|
||||
|
||||
condition:
|
||||
- condition: template
|
||||
- platform: template
|
||||
value_template: >
|
||||
{% set deadline_ts = as_timestamp(states('input_datetime.tesla_charge_deadline')) %}
|
||||
{% if deadline_ts %}
|
||||
{% set now_ts = as_timestamp(now()) %}
|
||||
{{ (deadline_ts - now_ts) <= 3600 }}
|
||||
|
||||
{% else %}
|
||||
false
|
||||
{% endif %}
|
||||
condition:
|
||||
- condition: numeric_state
|
||||
entity_id: sensor.tesla_kwh_needed
|
||||
above: 0
|
||||
|
||||
value_template: "{{ states('sensor.tesla_kwh_needed')|float(0) }}"
|
||||
action:
|
||||
- service: switch.turn_on
|
||||
target:
|
||||
|
||||
@@ -1,42 +1,59 @@
|
||||
- alias: Tesla smart charging v3
|
||||
mode: single
|
||||
id: tesla_smart_charging_v3
|
||||
mode: restart
|
||||
|
||||
trigger:
|
||||
- platform: time_pattern
|
||||
minutes: "/5"
|
||||
|
||||
condition:
|
||||
- condition: time
|
||||
before: input_datetime.tesla_charge_deadline
|
||||
# Ensure deadline is valid and in the future
|
||||
- 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:
|
||||
- choose:
|
||||
|
||||
# -------------------------
|
||||
# Charge if cheap
|
||||
# -------------------------
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: binary_sensor.tesla_charge_now
|
||||
state: "on"
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ states('binary_sensor.tesla_charge_now') == 'on' }}
|
||||
|
||||
sequence:
|
||||
# Reset hvis session står i connected_finished
|
||||
# Reset charger if stuck in finished state
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ states('sensor.home_charger_mode') == 'connected_finished' }}"
|
||||
value_template: >
|
||||
{{ states('sensor.home_charger_mode') == 'connected_finished' }}
|
||||
sequence:
|
||||
- service: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.home_charging
|
||||
- delay: "00:00:05"
|
||||
|
||||
# Turn charger on
|
||||
- service: switch.turn_on
|
||||
target:
|
||||
entity_id: switch.home_charging
|
||||
|
||||
# -------------------------
|
||||
# Stop charging if not cheap
|
||||
# -------------------------
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: binary_sensor.tesla_charge_now
|
||||
state: "off"
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ states('binary_sensor.tesla_charge_now') != 'on' }}
|
||||
|
||||
sequence:
|
||||
- service: switch.turn_off
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# template for "Tesla stop when charged"
|
||||
- alias: Tesla stop when charged
|
||||
trigger:
|
||||
- platform: template
|
||||
value_template: >
|
||||
{{ (states('sensor.snowywhite_battery') | default(0)) | float >=
|
||||
(states('number.snowywhite_charge_limit') | default(100)) | float }}
|
||||
|
||||
{{ (states('sensor.snowywhite_battery')|float(0)) >=
|
||||
(states('number.snowywhite_charge_limit')|float(100)) }}
|
||||
action:
|
||||
- service: switch.turn_off
|
||||
target:
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
- sensor:
|
||||
|
||||
- name: tesla_kwh_needed
|
||||
unit_of_measurement: "kWh"
|
||||
state: >
|
||||
{% set capacity = 75 %}
|
||||
{% set soc = states('sensor.snowywhite_battery')|float %}
|
||||
{% set limit = states('number.snowywhite_charge_limit')|float %}
|
||||
{% set soc = states('sensor.snowywhite_battery')|float(0) %}
|
||||
{% set limit = states('number.snowywhite_charge_limit')|float(100) %}
|
||||
{{ ((limit - soc)/100 * capacity)|round(2) }}
|
||||
|
||||
- name: tesla_charge_hours_needed
|
||||
unit_of_measurement: "h"
|
||||
state: >
|
||||
{% set power = 11 %}
|
||||
{% set kwh = states('sensor.tesla_kwh_needed')|float %}
|
||||
{% set kwh = states('sensor.tesla_kwh_needed')|float(0) %}
|
||||
{{ (kwh / power)|round(2) }}
|
||||
@@ -1,4 +1,4 @@
|
||||
binary_sensor:
|
||||
- binary_sensor:
|
||||
- name: tesla_charge_now
|
||||
state: >
|
||||
{% 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() %}
|
||||
|
||||
{{ cheapest | selectattr('hour','equalto',now_slot) | list | count > 0 }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user