Modified auto_AC accordingly to Gemini AI... TBT
This commit is contained in:
@@ -32,22 +32,37 @@ blueprint:
|
|||||||
filter:
|
filter:
|
||||||
- domain: climate
|
- domain: climate
|
||||||
|
|
||||||
mode: single
|
mode: restart
|
||||||
|
|
||||||
# Definiamo l'input come variabile per usarlo dentro i template dei trigger
|
# Calcoliamo matematicamente i valori statici qui per i trigger nativi
|
||||||
trigger_variables:
|
trigger_variables:
|
||||||
target_temp: !input temp_threshold
|
target_temp: !input temp_threshold
|
||||||
target_hist: !input temp_hist
|
target_hist: !input temp_hist
|
||||||
sensor_entity: !input climate_target
|
# Calcolo automatico della soglia di spegnimento (es. 29 - 2 = 27)
|
||||||
|
soglia_off: "{{ ( ( target_temp | float(0) ) - ( target_hist | float(0) ) ) | default(27.0) }}"
|
||||||
|
|
||||||
|
# Questa variabile serve SOLO per semplificare il codice dentro le azioni (actions)
|
||||||
|
variables:
|
||||||
|
target_AC: !input climate_target
|
||||||
|
|
||||||
triggers:
|
triggers:
|
||||||
# Si attiva quando la temperatura attuale del clima sale SOPRA la soglia impostata
|
# Si attiva IMMEDIATAMENTE se la temperatura sale sopra la soglia (o se abbassi la soglia sotto la temperatura attuale)
|
||||||
- trigger: template
|
- trigger: numeric_state
|
||||||
value_template: "{{ state_attr(sensor_entity, 'current_temperature') | float(0) >= target_temp | float(0) }}"
|
entity_id: !input climate_target
|
||||||
|
attribute: current_temperature
|
||||||
|
above: !input temp_threshold
|
||||||
id: AC_on
|
id: AC_on
|
||||||
# Si attiva quando la temperatura attuale del clima scende SOTTO la soglia meno 2 gradi
|
|
||||||
|
# Si attiva IMMEDIATAMENTE se la temperatura scende sotto la soglia meno l'isteresi
|
||||||
|
# AC_off: Risolve il problema del "none" calcolando l'isteresi con valori di ripiego sicuri per il reload YAML.
|
||||||
- trigger: template
|
- trigger: template
|
||||||
value_template: "{{ state_attr(sensor_entity, 'current_temperature') | float(0) < (target_temp | float(0) - temp_hist ) }}"
|
value_template: >-
|
||||||
|
{% set entity = '!input climate_target' %}
|
||||||
|
{% set current = state_attr(entity, 'current_temperature') | float(0) %}
|
||||||
|
{% set t_temp = target_temp | float(29.0) %}
|
||||||
|
{% set t_hist = target_hist | float(2.0) %}
|
||||||
|
{% set calcolo_soglia_off = t_temp - t_hist %}
|
||||||
|
{{ current < calcolo_soglia_off and current > 0 }}
|
||||||
id: AC_off
|
id: AC_off
|
||||||
|
|
||||||
conditions: []
|
conditions: []
|
||||||
@@ -68,7 +83,19 @@ actions:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input climate_target
|
entity_id: !input climate_target
|
||||||
data:
|
data:
|
||||||
fan_mode: Auto
|
fan_mode: >-
|
||||||
|
{% set curr_temp = state_attr(target_AC, 'current_temperature') | float(0) -%}
|
||||||
|
{% set targ_temp = state_attr(target_AC, 'temperature') | float(0) -%}
|
||||||
|
{% set diff_temp = curr_temp - targ_temp -%}
|
||||||
|
{% if diff_temp >= 4 -%}
|
||||||
|
5
|
||||||
|
{% elif diff_temp >= 3 and diff_temp < 4 -%}
|
||||||
|
4
|
||||||
|
{% elif diff_temp >= 2 and diff_temp < 3 -%}
|
||||||
|
3
|
||||||
|
{% else -%}
|
||||||
|
Auto
|
||||||
|
{% endif %}
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
id:
|
id:
|
||||||
|
|||||||
Reference in New Issue
Block a user