Files
N22/include/automations/vanding.yaml
T

194 lines
5.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
- alias: 'Vanding morgen kl. 06'
trigger:
platform: time
at: input_datetime.vanding_morgen_tid
action:
- service: script.vanding_hojbed_skiftevis
- alias: 'Vanding aften kl. 22'
trigger:
platform: time
at: input_datetime.vanding_aften_tid
action:
- service: script.vanding_hojbed_skiftevis
- alias: 'Vanding sikkerhedsstop morgen kl. 8'
trigger:
platform: time
at: input_datetime.vanding_sikkerhedsstop_morgen
action:
- service: script.turn_off
data:
entity_id: script.vanding_hojbed_skiftevis
- service: switch.turn_off
data:
entity_id:
- switch.hojbed_1
- switch.hojbed_2
- switch.drivhus_drypvanding
- service: switch.turn_off
data:
entity_id: switch.hovedhane_linktap
- alias: 'Vanding sikkerhedsstop nat kl. 23'
trigger:
platform: time
at: input_datetime.vanding_sikkerhedsstop_nat
action:
- service: script.turn_off
data:
entity_id: script.vanding_hojbed_skiftevis
- service: switch.turn_off
data:
entity_id:
- switch.hojbed_1
- switch.hojbed_2
- switch.drivhus_drypvanding
- service: switch.turn_off
data:
entity_id: switch.hovedhane_linktap
# --- Hovedhane (LinkTap) central afspærring før zonerne ---
- alias: 'Hovedhane åbn når en zone starter'
mode: queued
trigger:
- platform: state
entity_id:
- switch.hojbed_1
- switch.hojbed_2
- switch.hojbed_3
- switch.drivhus_drypvanding
to: 'on'
action:
# Åbn hovedhanen med lang sikkerhedsvarighed (120 min = maks) så LinkTap
# ikke selv lukker midt i en vanding. Lukkes eksplicit når alle zoner er
# slukket (eller af sikkerhedsstop-automationerne).
- service: linktap.start_watering
target:
entity_id: valve.hovedhane_linktap
data:
seconds: 7200
- alias: 'Hovedhane luk når alle zoner er slukket'
mode: queued
trigger:
- platform: state
entity_id:
- switch.hojbed_1
- switch.hojbed_2
- switch.hojbed_3
- switch.drivhus_drypvanding
to: 'off'
for: '00:00:25'
condition:
- condition: state
entity_id:
- switch.hojbed_1
- switch.hojbed_2
- switch.hojbed_3
- switch.drivhus_drypvanding
state: 'off'
action:
- service: switch.turn_off
data:
entity_id: switch.hovedhane_linktap
- alias: 'Hovedhane kapillærkasser periodisk vanding'
mode: single
trigger:
# Tjekker hver hele time om dette er et af de planlagte vandingstidspunkter
- platform: time_pattern
minutes: 0
condition:
# Er denne time et af de N tidspunkter jævnt fordelt mellem kl. 9 og 21?
# input_number.vanding_kapillaer_antal styrer antallet (0 = slået fra).
- condition: template
value_template: >
{% set n = states('input_number.vanding_kapillaer_antal') | int(3) %}
{% set ns = namespace(hours=[]) %}
{% for i in range(n) %}
{% set h = 9 + (((i + 0.5) * 12 / n) | round(0)) | int %}
{% set ns.hours = ns.hours + [h] %}
{% endfor %}
{{ now().hour in ns.hours }}
# Spring over ved regn eller aktiv regn-forsinkelse
- condition: state
entity_id: binary_sensor.annes_vanding_rainsensor
state: 'off'
- condition: numeric_state
entity_id: number.annes_vanding_rain_delay
below: 1
# Kør kun hvis ingen zonevanding er i gang
- condition: state
entity_id:
- switch.hojbed_1
- switch.hojbed_2
- switch.hojbed_3
- switch.drivhus_drypvanding
state: 'off'
action:
# Åbn kun hovedhanen i 15 min fylder kapillærkassernes flydventiler.
# LinkTap lukker selv efter varigheden (instant mode).
- service: select.select_option
target:
entity_id: select.vanding_liter
data:
option: kapillaer
- service: linktap.start_watering
target:
entity_id: valve.hovedhane_linktap
data:
seconds: 900
# --- Forside: sidst vandet & liter-måler pr. zone ---
- alias: 'Vanding opdater sidst vandet'
description: 'Sætter tidsstempel når en zone eller hovedhanen begynder at vande'
mode: queued
trigger:
- platform: state
entity_id:
- switch.hojbed_1
- switch.hojbed_2
- switch.hojbed_3
- switch.drivhus_drypvanding
to: 'on'
- platform: state
entity_id: binary_sensor.hovedhane_linktap_is_watering
to: 'on'
action:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.vanding_sidst_vandet
data:
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
- alias: 'Vanding vælg liter-tarif efter aktiv zone'
description: 'Skifter utility_meter-tarif så liter bogføres på det rette bed'
mode: queued
trigger:
- platform: state
entity_id: switch.hojbed_2 # Højbed 1 Ærter
to: 'on'
id: hb1
- platform: state
entity_id: switch.hojbed_1 # Højbed 2 Kartofler
to: 'on'
id: hb2
- platform: state
entity_id: switch.drivhus_drypvanding # Højbed 3 Rabarber
to: 'on'
id: hb3
- platform: state
entity_id: switch.hojbed_3 # Drivhus
to: 'on'
id: drivhus
action:
- service: select.select_option
target:
entity_id: select.vanding_liter
data:
option: "{{ trigger.id }}"