refactoring: use sections and use choose instead of if

This commit is contained in:
2025-12-06 12:42:40 +01:00
parent dfa2d15b27
commit f0eb9a8c25

View File

@@ -5,15 +5,28 @@ blueprint:
An automation to set Bosch TRV radiator valve to a desired temperature. An automation to set Bosch TRV radiator valve to a desired temperature.
domain: automation domain: automation
author: Me author: Me
input:
radiator_section:
name: Radiator Konfiguration
description: Konfiguration für den Bosch BTH-RA Radiator
collapsed: false
input: input:
radiator_entity: radiator_entity:
name: Thermostat name: Thermostat
description: Thermostat muss ein Bosch BTH-RA sein description: Thermostat muss ein Bosch BTH-RA sein
selector: selector:
entity: device:
multiple: false multiple: false
filter: filter:
- domain: climate - domain: climate
- integration: MQTT
- manufacturer: Bosch
- model_id: BTH-RA
window_section:
name: Fenster-/Türsensor Konfiguration
description: Konfiguration für den Fenster-/Türsensor.
collapsed: true
input:
window_sensor: window_sensor:
name: Fenster-/Türsensor (oder Gruppe) name: Fenster-/Türsensor (oder Gruppe)
selector: selector:
@@ -43,6 +56,11 @@ blueprint:
max: 3600.0 max: 3600.0
unit_of_measurement: seconds unit_of_measurement: seconds
step: 1.0 step: 1.0
remaining_section:
name: Weitere Konfiguration
description: Sonstige Konfigurationen für die Automation
collapesed: true
input:
temperature_sensor: temperature_sensor:
name: Temperatursensor name: Temperatursensor
selector: selector:
@@ -104,9 +122,8 @@ variables:
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{{ window_detection_entity_id.id }} {{ window_detection_entity_id.id }}
current_temperature: !input temperature_sensor current_temperature_entity_id: !input temperature_sensor
scheduled_temperature: > scheduled_temperature: >
{% set schedules = ['switch.schedule_bed7e4', 'switch.schedule_28375d', 'switch.schedule_0cc5de'] %}
{% set ns = namespace(current_temperature = none) %} {% set ns = namespace(current_temperature = none) %}
{% for schedule in schedules %} {% for schedule in schedules %}
{% if states(schedule) == 'on' and state_attr(schedule, 'current_slot') is not none %} {% if states(schedule) == 'on' and state_attr(schedule, 'current_slot') is not none %}
@@ -124,37 +141,38 @@ variables:
{{ ns.current_temperature }} {{ ns.current_temperature }}
actions: actions:
- if: - choose:
- conditions:
- condition: trigger - condition: trigger
id: id:
- FENSTER_OPEN - FENSTER_OPEN
then: sequence:
- service: switch.turn_on - service: switch.turn_on
target: target:
entity_id: "{{ window_detection_entity }}" entity_id: "{{ window_detection_entity }}"
alias: Setze Fenster auf offen alias: Setze Fenster auf offen
- if: - conditions:
- condition: trigger - condition: trigger
id: id:
- FENSTER_CLOSED - FENSTER_CLOSED
then: sequence:
- service: switch.turn_off - service: switch.turn_off
target: target:
entity_id: "{{ window_detection_entity }}" entity_id: "{{ window_detection_entity }}"
alias: Setze Fenster auf geschlossen alias: Setze Fenster auf geschlossen
# temperature sensor sync # temperature sensor sync
- if: - choose:
- conditions:
- condition: trigger - condition: trigger
id: id:
- FENSTER_OPEN - FENSTER_OPEN
- FENSTER_CLOSED - FENSTER_CLOSED
- SYNC_TEMPERATURE - SYNC_TEMPERATURE
- TEMP_CHANGED - TEMP_CHANGED
then: sequence:
- service: number.set_value - service: number.set_value
data: data:
value: "{{ states(current_temperature) | float }}" value: "{{ states(current_temperature_entity_id) | float }}"
target: target:
entity_id: "{{ remote_temperature_entity }}" entity_id: "{{ remote_temperature_entity }}"
alias: Sync remote temperature sensor
alias: Synce Temperatur zum TRV alias: Synce Temperatur zum TRV