Covers management

Hi guys,
currently i sue an automation to manage my 13 covers:

  • opening on the morning
  • closing on the evening
  • protection against sun's heat
    For those, i have defined several parameters by season for each cover (ie. elevation range, azimuth range, 4 percentage of closure to represent 4 step for sun's heat protection, morning authorisation, holidays autorisation, luminosity ...).
    All of those parameters represent currently more than 800 lines in the automation and the core (whitout the script for the common actions) less than 200 lines.

The issue i have: each time i want to setup or change parameters for 1 or more covers, i have to scroll more than 900 lines of the automation.

I would like know if it's possible to cahnge this way of working with (i'm not a programmer, so apologize for my approximatives explainations) as for example:

  • an independant YAML file which contents all covers' parameters (to avoid creation of more than 150 helpers)
  • the automation should have to "read" this file to exécute actions for one or more of the covers
  • a dashboard in which i would choose a cover and automatically all parameters of the regarding cover would be displayed and available for update.

It should be kind if someone could guide me in that way.

Thanks in advance for your help

One option is to create an input_number for each parameter, and call for these parameters in the automation. See:

You can then list these input numbers in a separate card, and modify them via the GUI.

1 Like

You can also post the actual automation for other improvements. 900 lines seem unmaintainable, even if you use helpers for your parameters.

Hi,
Thanks for your answer.

@thusassistint, as i said i would like avoid to create more than 150 helpers!
@parautenbach, please find below my automation (i didn't copied the script as it's not concerned by the "issue'.

Automation:

alias: VOLETS - Gestion Globale des Volets - V4
description: Ouverture le matin - Fermeture le soir - Protection contre la chaleur
triggers:
  - minutes: /2
    trigger: time_pattern
  - trigger: state
    entity_id:
      - input_boolean.volets_autoriser_fermeture
      - input_boolean.volets_autoriser_ouverture
    to:
      - "on"
actions:
  - repeat:
      for_each: "{{ volets }}"
      sequence:
        - variables:
            nom_volet: "{{ repeat.item.nom_volet }}"
            type_volet: "{{ repeat.item.type_volet }}"
            positions: "{{ repeat.item.positions }}"
            saison: "{{ states('sensor.season') }}"
            entity_statut: input_number.statut_volet_{{ nom_volet }}
            ouverture_matinale_entity: "{{ repeat.item.autorisation.ouverture_matinale }}"
            ouverture_matinale: |
              {{ is_state(ouverture_matinale_entity, 'on') }}
            calendrier_restriction: "{{ repeat.item.autorisation.calendrier_restriction }}"
            mot_cle_restriction: "{{ repeat.item.autorisation.mot_cle_restriction }}"
            message_calendrier: >-
              {{ state_attr('calendar.' ~ calendrier_restriction, 'message') |
              lower if calendrier_restriction else '' }}
            mot_cle_bloquant_present: >-
              {{ mot_cle_restriction and (mot_cle_restriction | lower in
              message_calendrier) }}
            azimuth_volet: "{{ repeat.item.azimuth.base | float }}"
            azimuth_min: "{{ azimuth_volet + (repeat.item.azimuth.min | float) }}"
            azimuth_max: "{{ azimuth_volet + (repeat.item.azimuth.max | float) }}"
            azimuth_soleil: "{{ state_attr('sun.sun', 'azimuth') | float }}"
            elevation_conf: >-
              {{ repeat.item.elevation[saison] if saison in
              repeat.item.elevation else repeat.item.elevation.default }}
            elevation_min: "{{ elevation_conf.min | float }}"
            elevation_max: >
              {% set val = elevation_conf.max %} {% if val is string and '.' in
              val %}
                {{ states(val) | float(0) }}
              {% else %}
                {{ val | float(0) }}
              {% endif %}
            elevation_soleil: "{{ state_attr('sun.sun', 'elevation') | float }}"
            soleil_dans_azimuth: >-
              {{ azimuth_soleil >= azimuth_min and azimuth_soleil <= azimuth_max
              }}
            soleil_dans_elevation: >-
              {{ elevation_soleil >= elevation_min and elevation_soleil <=
              elevation_max }}
            temperature_actuelle: "{{ states('sensor.ecowitt_sensor_ch3') | float(0) }}"
            uv_actuel: "{{ states('sensor.uv_filtre') | float(0) }}"
            seuil_temperature: |-
              {% if saison == "summer" %}
                {{ states('input_number.seuil_temp_summer') | float(25) }}
              {% elif saison == "spring" %}
                {{ states('input_number.seuil_temp_spring') | float(22) }}
              {% elif saison == "autumn" %}
                {{ states('input_number.seuil_temp_autumn') | float(22) }}
              {% elif saison == "winter" %}
                {{ states('input_number.seuil_temp_winter') | float(20) }}
              {% endif %}
            seuil_uv: "{{ states('input_number.seuil_uv') | float(0) }}"
            luminosite_actuelle: "{{ states('sensor.capteur_luminosite_eclairement') | float(0) }}"
            seuil_luminosite_exterieure: >-
              {{ states('input_number.seuil_luminosite_exterieure') | float(0)
              }}
            avec_luminosite: >-
              {{ repeat.item.autorisation.avec_luminosite | default(false) |
              bool }}
            pourcentage_ensoleillement: >-
              {% set az = azimuth_soleil %} {% if az < azimuth_min %}{% set az =
              azimuth_min %}{% endif %} {% if az > azimuth_max %}{% set az =
              azimuth_max %}{% endif %} {% set plage = azimuth_max - azimuth_min
              %} {% if plage > 0 %}{{ ((az - azimuth_min) / plage * 100) | round
              }} {% else %}0{% endif %}
            statut_actuel: "{{ states(entity_statut) | int(0) }}"
            condition_uv_luminosite: |-
              {{
                uv_actuel >= seuil_uv
                or (
                  avec_luminosite
                  and luminosite_actuelle >= seuil_luminosite_exterieure
                )
              }}
        - choose:
            - conditions:
                - condition: template
                  value_template: >-
                    {{ is_state('input_boolean.volets_autoriser_ouverture',
                    'on')
                       and statut_actuel == 0 and ouverture_matinale and not mot_cle_bloquant_present }}
              sequence:
                - choose:
                    - conditions:
                        - condition: template
                          value_template: "{{ statut_actuel != 5 }}"
                      sequence:
                        - data:
                            nom_volet: "{{ nom_volet }}"
                            type_volet: "{{ type_volet }}"
                            statut: 5
                            positions: "{{ positions }}"
                            saison: "{{ saison }}"
                            entity_statut: "{{ entity_statut }}"
                          action: script.gestion_volet_velux
                          continue_on_error: true
            - conditions:
                - condition: template
                  value_template: >-
                    {{ is_state('input_boolean.volets_autoriser_fermeture',
                    'on') }}
              sequence:
                - choose:
                    - conditions:
                        - condition: template
                          value_template: "{{ statut_actuel != 0 }}"
                      sequence:
                        - data:
                            nom_volet: "{{ nom_volet }}"
                            type_volet: "{{ type_volet }}"
                            statut: 0
                            positions: "{{ positions }}"
                            saison: "{{ saison }}"
                            entity_statut: "{{ entity_statut }}"
                          action: script.gestion_volet_velux
                          continue_on_error: true
            - conditions:
                - condition: template
                  value_template: |-

                    {{ soleil_dans_azimuth and soleil_dans_elevation
                       and temperature_actuelle >= seuil_temperature
                       and condition_uv_luminosite }}
              sequence:
                - variables:
                    nouveau_statut: |-
                      {% if pourcentage_ensoleillement >= 95 %}
                        4
                      {% elif pourcentage_ensoleillement >= 85 %}
                        3
                      {% elif pourcentage_ensoleillement >= 75 %}
                        2
                      {% else %}
                        1
                      {% endif %}
                - choose:
                    - conditions:
                        - condition: template
                          value_template: |
                            {{
                              statut_actuel == 5
                              or nouveau_statut | int > statut_actuel
                            }}
                      sequence:
                        - data:
                            nom_volet: "{{ nom_volet }}"
                            type_volet: "{{ type_volet }}"
                            statut: "{{ nouveau_statut | int }}"
                            positions: "{{ positions }}"
                            saison: "{{ saison }}"
                            entity_statut: "{{ entity_statut }}"
                          action: script.gestion_volet_velux
                          continue_on_error: true
            - conditions:
                - condition: template
                  value_template: |-

                    {{ not (soleil_dans_azimuth and soleil_dans_elevation
                       and temperature_actuelle >= seuil_temperature and condition_uv_luminosite)
                       and statut_actuel in [1, 2, 3, 4] }}
              sequence:
                - choose:
                    - conditions:
                        - condition: template
                          value_template: "{{ statut_actuel != 5 }}"
                      sequence:
                        - data:
                            nom_volet: "{{ nom_volet }}"
                            type_volet: "{{ type_volet }}"
                            statut: 5
                            positions: "{{ positions }}"
                            saison: "{{ saison }}"
                            entity_statut: "{{ entity_statut }}"
                          action: script.gestion_volet_velux
                          continue_on_error: true
                        - delay: "00:00:03"
mode: single
variables:
  volets:
    - nom_volet: cuisine_2
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 18
          "2": 25
          "3": 40
          "4": 80
          "5": 100
        summer:
          "0": 0
          "1": 15
          "2": 30
          "3": 60
          "4": 80
          "5": 100
        autumn:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        winter:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 230
        min: -10
        max: 70
      elevation:
        summer:
          min: 8
          max: input_number.elevation_soleil_max_du_jour
        default:
          min: 10
          max: input_number.elevation_soleil_max_du_jour
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_cuisine_2
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: false
    - nom_volet: sam_2
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 15
          "2": 20
          "3": 25
          "4": 25
          "5": 100
        summer:
          "0": 0
          "1": 15
          "2": 30
          "3": 60
          "4": 80
          "5": 100
        autumn:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        winter:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 230
        min: -10
        max: 70
      elevation:
        summer:
          min: 8
          max: input_number.elevation_soleil_max_du_jour
        default:
          min: 10
          max: input_number.elevation_soleil_max_du_jour
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_sam_2
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: true
    - nom_volet: sam_multimedia
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 15
          "2": 20
          "3": 25
          "4": 25
          "5": 100
        summer:
          "0": 0
          "1": 15
          "2": 30
          "3": 60
          "4": 80
          "5": 100
        autumn:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        winter:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 230
        min: -10
        max: 100
      elevation:
        summer:
          min: 8
          max: input_number.elevation_soleil_max_du_jour
        default:
          min: 10
          max: input_number.elevation_soleil_max_du_jour
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_sam_multimedia
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: true
    - nom_volet: bureau
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        summer:
          "0": 0
          "1": 15
          "2": 30
          "3": 60
          "4": 80
          "5": 100
        autumn:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        winter:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 230
        min: -10
        max: 70
      elevation:
        summer:
          min: 8
          max: input_number.elevation_soleil_max_du_jour
        default:
          min: 10
          max: input_number.elevation_soleil_max_du_jour
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_bureau
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: false
    - nom_volet: porte_entree
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        summer:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        autumn:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        winter:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 63
        min: -40
        max: 40
      elevation:
        summer:
          min: 20
          max: 45
        default:
          min: 10
          max: 60
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_porte_entree
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: false
    - nom_volet: fenetre_entree
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        summer:
          "0": 0
          "1": 15
          "2": 15
          "3": 30
          "4": 30
          "5": 100
        autumn:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        winter:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 63
        min: 30
        max: 80
      elevation:
        summer:
          min: 20
          max: 45
        default:
          min: 10
          max: 60
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_fenetre_entree
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: false
    - nom_volet: porte_pergola
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        summer:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        autumn:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        winter:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 152
        min: -40
        max: 40
      elevation:
        summer:
          min: 8
          max: 45
        default:
          min: 10
          max: 60
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_porte_pergola
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: false
    - nom_volet: chambre_parents
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        summer:
          "0": 0
          "1": 15
          "2": 30
          "3": 60
          "4": 80
          "5": 100
        autumn:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        winter:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 230
        min: -10
        max: 70
      elevation:
        summer:
          min: 8
          max: input_number.elevation_soleil_max_du_jour
        default:
          min: 10
          max: input_number.elevation_soleil_max_du_jour
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_chambre_parents
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: false
    - nom_volet: chambre_lili
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        summer:
          "0": 0
          "1": 15
          "2": 30
          "3": 60
          "4": 80
          "5": 100
        autumn:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        winter:
          "0": 0
          "1": 40
          "2": 60
          "3": 80
          "4": 90
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 230
        min: -10
        max: 70
      elevation:
        summer:
          min: 8
          max: input_number.elevation_soleil_max_du_jour
        default:
          min: 10
          max: input_number.elevation_soleil_max_du_jour
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_chambre_lili
        calendrier_restriction: vacances_petits_enfants
        mot_cle_restriction: Aurélie_Romain
        avec_luminosite: false
    - nom_volet: porte_thom
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        summer:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        autumn:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        winter:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 300
        min: -40
        max: 40
      elevation:
        summer:
          min: 8
          max: 45
        default:
          min: 10
          max: 60
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_porte_thom
        calendrier_restriction: vacances_petits_enfants
        mot_cle_restriction: Clovis_Auguste
        avec_luminosite: false
    - nom_volet: fenetre_thom
      type_volet: volet
      positions:
        spring:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        summer:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        autumn:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        winter:
          "0": 0
          "1": 100
          "2": 100
          "3": 100
          "4": 100
          "5": 100
        default:
          "0": 0
          "5": 100
      azimuth:
        base: 300
        min: -40
        max: 40
      elevation:
        summer:
          min: 8
          max: 45
        default:
          min: 10
          max: 60
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_fenetre_thom
        calendrier_restriction: vacances_petits_enfants
        mot_cle_restriction: Clovis_Auguste
        avec_luminosite: false
    - nom_volet: sam
      type_volet: velux
      positions:
        spring:
          "0": 45
          "1": 35
          "2": 27
          "3": 18
          "4": 10
          "5": 0
        summer:
          "0": 45
          "1": 35
          "2": 27
          "3": 18
          "4": 10
          "5": 0
        autumn:
          "0": 45
          "1": 35
          "2": 27
          "3": 18
          "4": 10
          "5": 0
        winter:
          "0": 45
          "1": 35
          "2": 27
          "3": 18
          "4": 10
          "5": 0
        default:
          "0": 45
          "5": 0
      azimuth:
        base: 63
        min: 30
        max: 120
      elevation:
        default:
          min: 10
          max: input_number.elevation_soleil_max_du_jour
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_sam
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: false
    - nom_volet: cuisine
      type_volet: velux
      positions:
        spring:
          "0": 45
          "1": 35
          "2": 27
          "3": 18
          "4": 10
          "5": 0
        summer:
          "0": 45
          "1": 35
          "2": 27
          "3": 18
          "4": 10
          "5": 0
        autumn:
          "0": 45
          "1": 35
          "2": 27
          "3": 18
          "4": 10
          "5": 0
        winter:
          "0": 45
          "1": 35
          "2": 27
          "3": 18
          "4": 10
          "5": 0
        default:
          "0": 45
          "5": 0
      azimuth:
        base: 63
        min: 30
        max: 120
      elevation:
        summer:
          min: 20
          max: input_number.elevation_soleil_max_du_jour
        default:
          min: 10
          max: input_number.elevation_soleil_max_du_jour
      autorisation:
        ouverture_matinale: input_boolean.ouverture_matinale_cuisine
        calendrier_restriction: ""
        mot_cle_restriction: ""
        avec_luminosite: false