diff --git a/Climate/bosch_bth-ra_control.yaml b/Climate/bosch_bth-ra_control.yaml index 3ef97e7..002d02b 100644 --- a/Climate/bosch_bth-ra_control.yaml +++ b/Climate/bosch_bth-ra_control.yaml @@ -1,12 +1,14 @@ mode: single blueprint: - name: Bosch BTH-RA Radiator Control + name: Bosch BTH-RA Radiator Control - DEV + homeassistant: + min_version: "2024.6.0" description: > - An automation to set Bosch TRV radiator valve to a desired temperature. + Eine Automation zur automatischen Steuerung eines Bosch TRV Heizkörperthermostats. domain: automation author: Me input: - radiator_entity: + trv: name: Thermostat description: Thermostat muss ein Bosch BTH-RA sein selector: @@ -14,43 +16,101 @@ blueprint: multiple: false filter: - domain: climate - window_sensor: - name: Fenster-/Türsensor (oder Gruppe) - selector: - entity: - multiple: false - filter: - - domain: binary_sensor - window_delay_open: - name: Fenster-/Türsensor Verzögerung - description: Zeit die das Fenster offen bleiben muss, um die den Radiator in den "Fenster offen"-Modus zu versetzen (Default = 30s) - default: 30 - selector: - number: - mode: box - min: 0.0 - max: 3600.0 - unit_of_measurement: seconds - step: 1.0 - window_delay_close: - name: Fenster-/Türsensor Verzögerung - description: Zeit die das Fenster geschlossen bleiben muss, um die den Radiator in den "Fenster geschlossen"-Modus zu versetzen (Default = 5s) - default: 5 - selector: - number: - mode: box - min: 0.0 - max: 3600.0 - unit_of_measurement: seconds - step: 1.0 - temperature_sensor: - name: Temperatursensor - selector: - entity: - multiple: false - filter: - - domain: sensor - device_class: temperature + window_section: + name: Fenster-/Türsensor Konfiguration + description: Konfiguration für den Fenster-/Türsensor. + collapsed: false + input: + window_sensor: + name: Fenster-/Türsensor (oder Gruppe) + selector: + entity: + multiple: false + filter: + - domain: binary_sensor + window_delay_open: + name: Fenster-/Türsensor Verzögerung + description: Zeit die das Fenster offen bleiben muss, um die den Radiator in den "Fenster offen"-Modus zu versetzen (Default = 30s) + default: 30 + selector: + number: + mode: box + min: 0.0 + max: 3600.0 + unit_of_measurement: seconds + step: 1.0 + window_delay_close: + name: Fenster-/Türsensor Verzögerung + description: Zeit die das Fenster geschlossen bleiben muss, um die den Radiator in den "Fenster geschlossen"-Modus zu versetzen (Default = 5s) + default: 5 + selector: + number: + mode: box + min: 0.0 + max: 3600.0 + unit_of_measurement: seconds + step: 1.0 + remaining_section: + name: Weitere Konfiguration + description: Sonstige Konfigurationen für die Automation + collapsed: false + input: + temperature_sensor: + name: Temperatursensor + selector: + entity: + multiple: false + filter: + - domain: sensor + device_class: temperature + radiator_schedules: + name: Heizpläne + description: Alle Heizpläne die für den Radiator berücksichtigt werden sollen. Sind mehrere Schedules aktiv, wird der erste mit einem gültigen Slot verwendet. + default: [] + selector: + entity: + multiple: true + filter: + - domain: switch + +variables: + trv: !input trv + radiator_schedules: !input radiator_schedules + temperature_sensor: !input temperature_sensor + remote_temperature_entity: > + {% set entities = device_entities(device_id(trv)) %} + {% set remote_temperature_entity_id = namespace(id='') %} + {% for entity in entities %} + {% if 'remote_temperature' in entity %} + {% set remote_temperature_entity_id.id = entity %} + {% endif %} + {% endfor %} + {{ remote_temperature_entity_id.id }} + window_detection_entity: > + {% set entities = device_entities(device_id(trv)) %} + {% set window_detection_entity_id = namespace(id='') %} + {% for entity in entities %} + {% if 'window_detection' in entity %} + {% set window_detection_entity_id.id = entity %} + {% endif %} + {% endfor %} + {{ window_detection_entity_id.id }} + scheduled_temperature: > + {% set ns = namespace(current_temperature = none) %} + {% for schedule in radiator_schedules %} + {% if states(schedule) == 'on' and state_attr(schedule, 'current_slot') is not none %} + {% set current_slot = state_attr(schedule, 'current_slot') %} + {% set actions = state_attr(schedule, 'actions') %} + {% if actions is not none and actions | length > current_slot %} + {% set action = actions[current_slot] %} + {% if action.data.temperature is defined %} + {% set ns.current_temperature = action.data.temperature %} + {% break %} + {% endif %} + {% endif %} + {% endif %} + {% endfor %} + {{ ns.current_temperature }} triggers: - trigger: state @@ -75,60 +135,53 @@ triggers: entity_id: !input temperature_sensor id: TEMP_CHANGED -variables: - trv: !input radiator_entity - remote_temperature_entity: > - {% set entities = device_entities(device_id(trv)) %} - {% set remote_temperature_entity_id = namespace(id='') %} - {% for entity in entities %} - {% if 'remote_temperature' in entity %} - {% set remote_temperature_entity_id.id = entity %} - {% endif %} - {% endfor %} - {{ remote_temperature_entity_id.id }} - window_detection_entity: > - {% set entities = device_entities(device_id(trv)) %} - {% set window_detection_entity_id = namespace(id='') %} - {% for entity in entities %} - {% if 'window_detection' in entity %} - {% set window_detection_entity_id.id = entity %} - {% endif %} - {% endfor %} - {{ window_detection_entity_id.id }} - current_temperature: !input temperature_sensor - actions: -- if: - - condition: trigger - id: - - FENSTER_OPEN - then: - - service: switch.turn_on - target: - entity_id: "{{ window_detection_entity }}" - alias: Setze Fenster auf offen -- if: - - condition: trigger - id: - - FENSTER_CLOSED - then: - - service: switch.turn_off - target: - entity_id: "{{ window_detection_entity }}" - alias: Setze Fenster auf geschlossen + - choose: + - conditions: + - condition: trigger + id: + - FENSTER_OPEN + - condition: template + value_template: > + {{ is_state(window_detection_entity, 'off') }} + sequence: + - service: switch.turn_on + target: + entity_id: "{{ window_detection_entity }}" + alias: Setze Fenster auf offen + - conditions: + - condition: trigger + id: + - FENSTER_CLOSED + - condition: template + value_template: > + {{ is_state(window_detection_entity, 'on') }} + sequence: + - service: switch.turn_off + target: + entity_id: "{{ window_detection_entity }}" + - if: + - condition: template + value_template: > + {{ scheduled_temperature is not none }} + then: + - action: climate.set_temperature + target: + entity_id: !input trv + data: + temperature: "{{ scheduled_temperature | float }}" + alias: Setze Fenster auf geschlossen und setze Solltemperatur auf Wert aus Zeitplan (wenn vorhanden) # temperature sensor sync -- if: - - condition: trigger - id: - - FENSTER_OPEN - - FENSTER_CLOSED - - SYNC_TEMPERATURE - - TEMP_CHANGED - then: - - service: number.set_value - data: - value: "{{ states(current_temperature) | float }}" - target: - entity_id: "{{ remote_temperature_entity }}" - alias: Sync remote temperature sensor - alias: Synce Temperatur zum TRV \ No newline at end of file + - choose: + - conditions: + - condition: trigger + id: + - SYNC_TEMPERATURE + - TEMP_CHANGED + sequence: + - service: number.set_value + data: + value: "{{ states(temperature_sensor) | float }}" + target: + entity_id: "{{ remote_temperature_entity }}" + alias: Synchronisiere Temperatur am TRV \ No newline at end of file