Advertisement
energywave

Finestre aperte troppo a lungo

Oct 6th, 2022
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.02 KB | None | 0 0
  1. binary_sensor:
  2.   - platform: group
  3.     name: "Finestre mansarda"
  4.     device_class: opening
  5.     unique_id: 719f1a3c-b07d-4ebc-afb6-5898d08836fd
  6.     entities:
  7.      - binary_sensor.finestra_mansarda_letto
  8.       - binary_sensor.finestra_mansarda_pc
  9.       - binary_sensor.lucernario_pc_sx
  10.       - binary_sensor.lucernario_cameretta_erica
  11.  
  12.   - platform: group
  13.     name: "Finestre pian terreno"
  14.     device_class: opening
  15.     unique_id: dad0d5ec-10dc-4ba7-949f-4de5bb8c3c09
  16.     entities:
  17.      - binary_sensor.porta_ingresso
  18.       - binary_sensor.finestra_cucina
  19.       - binary_sensor.portafinestra_cucina
  20.       - binary_sensor.finestra_soggiorno_dx
  21.       - binary_sensor.finestra_soggiorno_sx
  22.  
  23.   - platform: group
  24.     name: "Finestre camera"
  25.     device_class: opening
  26.     unique_id: 7a4288e2-2794-4078-9726-1a88abde638d
  27.     entities:
  28.      - binary_sensor.finestra_camera
  29.       - binary_sensor.portafinestra_camera
  30.  
  31.   - platform: group
  32.     name: "Finestre cameretta"
  33.     device_class: opening
  34.     unique_id: 3b4e15f8-5996-42dd-a442-768801f41999
  35.     entities:
  36.      - binary_sensor.finestra_cameretta
  37.       - binary_sensor.portafinestra_cameretta
  38.  
  39.   - platform: group
  40.     name: "Finestre corridoio"
  41.     device_class: opening
  42.     unique_id: cf58a846-fee0-483e-9ec9-c42218808f21
  43.     entities:
  44.      - binary_sensor.finestra_corridoio
  45.       - binary_sensor.finestra_scale
  46.  
  47. # Automazione che gestisce l'apertura delle finestre di una stanza e attende fino alla chiusura, con ripristino riscaldamento
  48. # Funziona per qualunque stanza, basta aggiungere nei trigger il relativo gruppo (da creare qui sopra) che VA INSERITO NELL'AREA CORRETTA TRAMITE UI!
  49. automation:
  50.   - alias: "Stanza aperta"
  51.     mode: parallel
  52.     trigger:
  53.       - platform: state
  54.         entity_id: binary_sensor.finestre_mansarda
  55.         for: "00:00:30"
  56.         to: "on"
  57.       - platform: state
  58.         entity_id: binary_sensor.finestre_pian_terreno
  59.         for: "00:00:30"
  60.         to: "on"
  61.       - platform: state
  62.         entity_id: binary_sensor.finestre_camera
  63.         for: "00:00:30"
  64.         to: "on"
  65.       - platform: state
  66.         entity_id: binary_sensor.finestre_cameretta
  67.         for: "00:00:30"
  68.         to: "on"
  69.       - platform: state
  70.         entity_id: binary_sensor.finestra_bagno
  71.         for: "00:00:30"
  72.         to: "on"
  73.       - platform: state
  74.         entity_id: binary_sensor.lucernario_bagno_mansarda
  75.         for: "00:00:30"
  76.         to: "on"
  77.       - platform: state
  78.         entity_id: binary_sensor.finestre_corridoio
  79.         for: "00:00:30"
  80.         to: "on"
  81.     condition:
  82.       - condition: state
  83.         entity_id: input_boolean.estate
  84.         state: "off"
  85.     action:
  86.       - variables:
  87.           source_entity_id: trigger.entity_id
  88.           # source_area: '{{entity_id | regex_findall("\w+\.\w+\_(\w+)\_\w+") | first}}'
  89.           source_area_id: "area_id(source_entity_id)"
  90.           source_area_name: "area_name(source_area_id)"
  91.           climate_entity_id: "{{ expand(states.climate) | selectattr('entity_id', 'in', area_entities(source_area_id)) | selectattr('attributes.supported_features', 'eq', 17) | map(attribute='entity_id') | list | first | default('') }}"
  92.       #TODO: Rilevare se il source_entity_id non appartiene ad alcuna area e dare un messaggio specifico interrompendo l'automazione
  93.       # Se configurato di spegnere il riscaldamento dopo un tot che è aperta lo faccio
  94.       - choose:
  95.           conditions:
  96.             - condition: state
  97.               entity_id: input_boolean.spegnimento_riscaldamento_finestre
  98.               state: "on"
  99.             - "{{climate_entity_id != ''}}"
  100.           sequence:
  101.             - service: script.spegni_riscaldamento
  102.               data:
  103.                 entity: "{{climate_entity_id}}"
  104.       # Attendo un delay e loop notifiche finchè ancora aperta
  105.       - wait_template: "{{is_state(trigger.entity_id, 'off')}}"
  106.         timeout:
  107.           minutes: "{{ states('input_number.ritardo_notifiche_finestre_min') | int}}"
  108.       - repeat:
  109.           while:
  110.            - "{{is_state(trigger.entity_id, 'on')}}"
  111.             - condition: state
  112.               entity_id: input_boolean.notifiche_finestre
  113.               state: "on"
  114.           sequence:
  115.             - service: script.multinotify
  116.               data:
  117.                 title: "Finestre {{source_area_name}} aperte troppo a lungo"
  118.                 message: >
  119.                  {% set minuti = ((now().timestamp()-as_timestamp(trigger.to_state.last_changed)) / 60)|round(0) %}
  120.                   {{[ source_area_name ~ " ha le finestre aperte da " ~ minuti ~ " minuti!",
  121.                      "I pinguini scorazzano liberamente in " ~ source_area_name ~ " ormai da " ~ minuti ~ " minuti!",
  122.                      "Il ghiaccio sta prendendo il sopravvento da " ~ minuti ~ " minuti, in " ~ source_area_name ~ "!",
  123.                      "Fa freschino in " ~ source_area_name ~ ", le finestre sono aperte da " ~ minuti ~ " minuti!",
  124.                      "Io dico che dopo " ~ minuti ~ " minuti di cambio aria puoi chiudere le finestre di " ~ source_area_name ~ "!",
  125.                      "Secondo me " ~ minuti ~ " minuti di finestre aperte possono bastare, in " ~ source_area_name ~ "!",
  126.                      "Hey, che ne dici di chiudere le finestre di " ~ source_area_name ~ "? " ~ minuti ~ " minuti di cambio aria sono abbastanza!"] | random}}
  127.                 notify_app:
  128.                  - notify.all_android_devices
  129.                   - notify.all_ios_devices
  130.                 channel: warning
  131.                 critical: true
  132.                 alexa_target: media_player.ovunque
  133.             - wait_template: "{{is_state(trigger.entity_id, 'off')}}"
  134.               timeout:
  135.                 minutes: "{{ states('input_number.ritardo_notifiche_finestre_min') | int}}"
  136.       - wait_template: "{{is_state(trigger.entity_id, 'off')}}"
  137.       - choose:
  138.           conditions:
  139.            - "{{climate_entity_id != ''}}"
  140.           sequence:
  141.             - service: script.imposta_riscaldamento
  142.               data:
  143.                 entity: "{{climate_entity_id}}"
  144.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement