# Alerte météo ( archive )

**URL:** <https://forum.hacf.fr/t/alerte-meteo-archive/23930>\
**Category:** Entraide Home Assistant\
**Created:** [Mai 15, 2023, 2:30 UTC](https://forum.hacf.fr/t/alerte-meteo-archive/23930 "2023-05-15T14:30:05Z")\
**Posts on this page:** 1\
**Showing post:** 512

<div class="post-metadata">

**Author:** ![starworld](https://forum.hacf.fr/user_avatar/forum.hacf.fr/starworld/32/21732_2.png) [@starworld](https://forum.hacf.fr/u/starworld)\
**Post date:** [Juillet 3, 2024, 3:48 UTC](https://forum.hacf.fr/t/alerte-meteo-archive/23930/512 "2024-07-03T15:48:19Z")

</div>

Je propose une mise à jour de la configuration. Plus de rapport d'erreur, retente plusieurs fois en cas d'erreur et en cas de réel échec de maj affiche une carte grise et retentera de mettre à jour par la suite.

* * *

**- API Météo France :**

Il faut créer un compte sur [https://portail-api.meteofrance.fr/](https://portail-api.meteofrance.fr/)  
_(Pour info mémoriser bien le nom d'utilisateur pour vous connecter au site car ce n'est pas avec l'email)_  
Ensuite rendez vous ici : [https://portail-api.meteofrance.fr/web/fr/api/DonneesPubliquesVigilance](https://portail-api.meteofrance.fr/web/fr/api/DonneesPubliquesVigilance)  
Cliquez sur `Configurer l'API`.  
Vous êtes maintenant sur la page CONFIGURER L'API BULLETIN VIGILANCE.  
Dans TYPE DE TOKEN sélectionner `API Key` puis mettre la durée `94672800` soit 3 ans.  
Cliquez sur bouton Générer le Token.  
Attention copier bien votre key car elle n'est pas disponible ensuite!  
Dans votre compte [Mes API](https://portail-api.meteofrance.fr/web/fr/dashboard) vous avez un rappel de votre "abonnement".

**- Configuration :**

Ouvrir File editor cliquez sur l'icon dossier en haut à gauche, vous devez être dans le dossier `homeassistant/` (ou `config/`), ajouter cette ligne dans le fichier configuration.yaml :

```auto
command_line: !include command_line.yaml

```

> **camera à ajouter dans configuration.yaml**
>
> ```auto
> camera:
> - platform: local_file
> name: MF_alerte_today
> file_path: /config/www/weather/meteo_france_alerte_today.png
> - platform: local_file
> name: MF_alerte_tomorrow
> file_path: /config/www/weather/meteo_france_alerte_tomorrow.png
> 
> ```

Sauvegardez avec l'icon rouge.

Cliquez sur l'icon fichier+ pour créé un fichier `command_line.yaml`.  
Puis ajouter ceci :

> **sensor à ajouter dans command\_line.yaml**
>
> ```auto
> - sensor:
> name: Météo France alertes image today
> unique_id: meteo_france_alertes_image_today
> scan_interval: 14400
> command_timeout: 10
> command: |-
> api_key="METTRE_API_KEY_ICI";
> i=0;
> while true; do
> today=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/vignettenationale-J/encours" -H "accept: */*" -H "apikey: $api_key"| base64 -w 0);
> $((i++));
> if [[$(expr length "$today") -gt "10000"]];
> then
> echo "$today" | base64 -d > ./www/weather/meteo_france_alerte_today.png;
> echo on;
> break;
> elif [["$i" == '5']];
> then
> cp -f "./www/weather/meteo_france_alerte_nodata.png" "./www/weather/meteo_france_alerte_today.png";
> echo unavailable;
> break;
> fi
> sleep 1;
> done
> value_template: "{{value}}"
> 
> - sensor:
> name: Météo France alertes image tomorrow
> unique_id: meteo_france_alertes_image_tomorrow
> scan_interval: 14400
> command_timeout: 10
> command: |-
> api_key="METTRE_API_KEY_ICI";
> i=0;
> while true; do
> today=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/vignettenationale-J1/encours" -H "accept: */*" -H "apikey: $api_key"| base64 -w 0);
> $((i++));
> if [[$(expr length "$today") -gt "10000"]];
> then
> echo "$today" | base64 -d > ./www/weather/meteo_france_alerte_tomorrow.png;
> echo on;
> break;
> elif [["$i" == '5']];
> then
> cp -f "./www/weather/meteo_france_alerte_nodata.png" "./www/weather/meteo_france_alerte_tomorrow.png";
> echo unavailable;
> break;
> fi
> sleep 1;
> done
> value_template: "{{value}}"
> 
> ```

Remplacer la texte `METTRE_API_KEY_ICI` (2 fois) par votre clé.  
Sauvegardez avec l'icon rouge.

Ouvrir File editor cliquez sur l'icon dossier en haut à gauche, vous devez avoir le dossier `homeassistant/` (ou `config/` suivant l'interface utilisé).  
Allez dans le dossier `www` puis cliquez sur l'icon dossier+ pour créé un dossier `weather`.  
Dans le dossier `weather` cliquez sur l'icon Upload File et sélectionner le fichier `meteo_france_alerte_nodata.png` que vous avez télécharger ci dessous et renommer.

 ![meteo_france_alerte_nodata.png](https://forum.hacf.fr/uploads/default/original/3X/8/d/8d0881c5e6d2d381a7b7529367b3a5436b6071b2.png)

Automatisation pour actualiser les cartes :

> **Automatisation**
>
> ```auto
> alias: Alerte Météo France actualisation
> description: ""
> trigger:
> - platform: homeassistant
> event: start
> id: Start
> - platform: time
> at: "06:32:00"
> id: Heure632
> - platform: time
> at: "16:32:00"
> id: Heure1632
> - platform: time_pattern
> minutes: /5
> id: Toutesles5minutes
> condition:
> - condition: or
> conditions:
> - condition: trigger
> id:
> - Start
> - condition: trigger
> id:
> - Heure632
> - condition: trigger
> id:
> - Heure1632
> - condition: and
> conditions:
> - condition: trigger
> id:
> - Toutesles5minutes
> - condition: state
> entity_id: sensor.meteo_france_alertes_image_today
> state: unavailable
> alias: 5minutesETtoday
> - condition: and
> conditions:
> - condition: trigger
> id:
> - Toutesles5minutes
> - condition: state
> entity_id: sensor.meteo_france_alertes_image_tomorrow
> state: unavailable
> alias: 5minutesETtomorrow
> action:
> - service: homeassistant.update_entity
> data: {}
> target:
> entity_id: sensor.meteo_france_alertes_image_today
> - service: homeassistant.update_entity
> data: {}
> target:
> entity_id:
> - sensor.meteo_france_alertes_image_tomorrow
> - delay:
> hours: 0
> minutes: 0
> seconds: 5
> milliseconds: 0
> - alias: Répéter MAJ Today
> repeat:
> count: 1
> sequence:
> - if:
> - condition: state
> entity_id: sensor.meteo_france_alertes_image_today
> state: unavailable
> then:
> - service: homeassistant.update_entity
> target:
> entity_id: sensor.meteo_france_alertes_image_today
> data: {}
> - delay:
> hours: 0
> minutes: 0
> seconds: 5
> milliseconds: 0
> - alias: Répéter MAJ Tomorrow
> repeat:
> count: 1
> sequence:
> - if:
> - condition: state
> entity_id: sensor.meteo_france_alertes_image_tomorrow
> state: unavailable
> then:
> - service: homeassistant.update_entity
> data: {}
> target:
> entity_id: sensor.meteo_france_alertes_image_tomorrow
> - delay:
> hours: 0
> minutes: 0
> seconds: 5
> milliseconds: 0
> - service: homeassistant.update_entity
> data: {}
> target:
> entity_id:
> - camera.mf_alerte_today
> - camera.mf_alerte_tomorrow
> mode: single
> 
> ```

Allez dans `Outils de développement > Vérifier la configuration`.  
Si il n'y a pas d'erreur cliquez `Redémarrer`.

**- Carte :**

Pour visualiser toutes les informations voila ma carte :

 ![meteo_france_alerte_card](https://forum.hacf.fr/uploads/default/original/3X/e/b/eb4b91289d7116fbfcc49da92fc0323981b934f1.jpeg)

> **Card**
>
> ```auto
> type: horizontal-stack
> cards:
> - type: conditional
> conditions:
> - condition: state
> entity: sensor.meteo_france_alertes_image_today
> state_not: unknown
> card:
> type: custom:button-card
> entity: camera.mf_alerte_today
> name: Aujourd'hui
> show_icon: false
> show_entity_picture: true
> aspect_ratio: 1/1
> size: 100%
> card_mod:
> style: |
> ha-card {
> margin: 0px 0px 5px 0px;
> box-shadow: 2px 2px 4px 0px rgba(0,0,0,0.5) !important;
> border: 1px rgba(0,0,0,1.0) outset;
> }
> - type: conditional
> conditions:
> - condition: state
> entity: sensor.meteo_france_alertes_image_tomorrow
> state_not: unknown
> card:
> type: custom:button-card
> entity: camera.mf_alerte_tomorrow
> name: Demain
> aspect_ratio: 1/1
> show_icon: false
> show_entity_picture: true
> size: 100%
> card_mod:
> style: |
> ha-card {
> margin: 0px 0px 5px 0px;
> box-shadow: 2px 2px 4px 0px rgba(0,0,0,0.5) !important;
> border: 1px rgba(0,0,0,1.0) outset;
> }
> 
> ```

---

_[View the full topic](https://forum.hacf.fr/t/alerte-meteo-archive/23930)._
