home assistant : Afficher les risques d’averses météo France

L’intégration Météo-France donne accès aux prévisions d’averses à une heure.
dans l’ancienne integration, l’information était disponible toutes les 5 minutes, dorénavant vous avez les infos pour :
0 min, 5 min, 10 min, 15 min, 20 min, 25 min, 35 min, 45 min, 55 min. (30, 40, 50 ne sont plus disponible)
je vous propose ici le code de [weado](https://community.home-assistant.io/u/weado) mis à jour par mes soins pour fonctionner avec la derniere version de l »intégration Météo-France (>=0.115.x).
Avec en plus une condition pour n’afficher les informations qu’en cas d’averse prévue.
cela donne ça (avec mon thème dark)

# https://forum.hacf.fr/t/afficher-les-risques-daverses-meteo-france/579
# https://community.home-assistant.io/t/new-custom-component-france-weather-alerts-from-meteo-france/55831/79
          - type: vertical-stack
            cards: 
              - type: conditional
                conditions:
                  - entity: sensor.limoges_next_rain
                    state_not: "unknown"
                card:
                  type: entities
                  entities:
                    - entity: sensor.limoges_next_rain
                      name: Averse
              - type: conditional
                conditions:
                  - entity: sensor.limoges_next_rain
                    state_not: "unknown"
                card:
                  type: horizontal-stack
                  cards:
                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: "0"
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['0 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'  
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['0 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)' 
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['0 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: 05
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['5 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['5 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['5 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: 10
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['10 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['10 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['10 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: 15
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['15 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['15 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['15 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: 20
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['20 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['20 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['20 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: 25
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['25 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['25 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['25 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: 35
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['35 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['35 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['35 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: 45
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['45 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['45 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['45 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

                    - color_type: card
                      entity: sensor.limoges_next_rain
                      name: 55
                      show_icon: false
                      show_state: false
                      state:
                        - color: 'rgb(204, 217, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['55 min'] == 'Pluie faible')
                            ]]]
                        - color: 'rgb(128, 159, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['55 min'] == 'Pluie modérée')
                            ]]]
                        - color: 'rgb(51, 102, 255)'
                          operator: template
                          value: |
                            [[[
                              return states['sensor.limoges_next_rain'].attributes
                              && (states['sensor.limoges_next_rain'].attributes['1_hour_forecast']['55 min'] == 'Pluie forte')
                            ]]]
                        - color: 'rgb(255, 255, 255)'
                          operator: default
                      styles:
                        card:
                          - height: 50px
                      type: 'custom:button-card'

###########################################################################

Laisser un commentaire