Oui il me semble je crois
Donc, si tu met domain_ids[31] c’est pour dept. 42 et pas pour 31
Oui, pour le département 31 c’est 20 effectivement
Le mieux c’est de télécharger le fichier entier via le portail et le regarder sur https://jsonpathfinder.com/ pour bien identifier les éléments que l’on souhaite
Bonjour,
Merci @R_hum1 pour ces explication avec l’api de météo france.
Après quelque essaie j’y suis arrivé et je me demander si on pouvait pas utiliser l’option attribut pour importer plus d’information dans le même sensor ?
Comme ça
EDIT: optimalisaiton dessous
petite correction / simplification
EDIT: correction, voir dessous
pour la carte de la France
- sensor:
name: meteo_france_alerts_picture_today
scan_interval: 7200
command: >
curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/vignettenationale-J/encours" -H "accept: */*" -H "apikey: KEYKEY" > ./www/pictures/meteo_france_alert_today.jpg
value_template: "mf_alert_today"
unique_id: meteo_france_alerts_picture_today
- sensor:
name: meteo_france_alerts_picture_tomorrow
scan_interval: 7200
command: >
curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/vignettenationale-J1/encours" -H "accept: */*" -H "apikey: KEYKEY" > ./www/pictures/meteo_france_alert_tomorrow.jpg
value_template: "mf_alert_tomorrow"
unique_id: meteo_france_alerts_picture_tomorrow
type: horizontal-stack
cards:
- type: vertical-stack
cards:
- type: conditional
conditions:
- entity: sensor.meteo_france_alerts_06
state_not: 1
card:
type: custom:button-card
entity_picture: /local/pictures/meteo_france_alert_today.jpg
name: Aujourdhui
aspect_ratio: 4/3
show_entity_picture: true
size: 80%
- type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Wind
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:weather-windy
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[0].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[0].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[0].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Rain
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:weather-rainy
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[1].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[1].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[1].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Storm
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:weather-partly-lightning
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[2].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[2].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[2].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Flood
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:home-flood
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[3].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[3].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[3].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Snow
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:weather-snowy
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[4].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[4].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[4].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Hot
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:temperature-celsius
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[5].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[5].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[5].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Cold
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: si:snowflake
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (entity.attributes.today.length == 7) {
if (
entity.attributes.today[6].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[6].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[6].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; } else
return 'grey'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Avalanches
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: si:snowpack
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (entity.attributes.today.length == 8) {
if (
entity.attributes.today[7].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[7].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[7].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; } else
return 'grey'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Vagues Submersion
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: si:flood
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (entity.attributes.today.length == 9) {
if (
entity.attributes.today[8].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[8].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[8].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; } else
return 'grey'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: vertical-stack
cards:
- type: conditional
conditions:
- entity: sensor.meteo_france_alerts_06
state_not: 1
card:
type: custom:button-card
entity_picture: /local/pictures/meteo_france_alert_tomorrow.jpg
name: Demain
aspect_ratio: 4/3
show_entity_picture: true
size: 80%
- type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Wind
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:weather-windy
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[0].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[0].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[0].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Rain
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:weather-rainy
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[1].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[1].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[1].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Storm
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:weather-partly-lightning
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[2].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[2].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[2].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Flood
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:home-flood
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[3].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[3].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[3].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Snow
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:weather-snowy
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[4].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[4].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[4].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Hot
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: mdi:temperature-celsius
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (
entity.attributes.today[5].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[5].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[5].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Cold
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: si:snowflake
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (entity.attributes.today.length == 7) {
if (
entity.attributes.today[6].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[6].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[6].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; } else
return 'grey'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Avalanches
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: si:snowpack
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (entity.attributes.today.length == 8) {
if (
entity.attributes.today[7].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[7].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[7].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; } else
return 'grey'; ]]]
style: |
ha-card {
top: 1px !important;
}
- type: custom:button-card
entity: sensor.meteo_france_alerts_06
name: Vagues Submersion
aspect_ratio: 4/3
show_state: false
show_icon: true
icon: si:flood
size: 100%
styles:
card:
- '--mdc-ripple-color': rgb(68, 115, 158)
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 0.85em
state:
- font-size: 0.7em
icon:
- color: >
[[[ if (entity.attributes.today.length == 9) {
if (
entity.attributes.today[8].phenomenon_max_color_id
== 1 ) return 'green'; else if (
entity.attributes.today[8].phenomenon_max_color_id
== 2 ) return 'yellow'; else if (
entity.attributes.today[8].phenomenon_max_color_id
== 3 ) return 'orange'; else return 'red'; } else
return 'grey'; ]]]
style: |
ha-card {
top: 1px !important;
}
Seul chose à faire…j’ai pas des beaux icones pour tous
C’est bon, mais c’est normal qui est pas d’état ?
j’ai que les attributs.
Oui… pas besoin pour un ‹ state ›
EDIT, il est dans le sensor…on peut l’utiliser SI on veut
Je savais pas qu’on pouvais créer un sensor sans state
Utiliser les attributs est pas un soucis
Le state = « mf_alert_today »
On peut changer pour qq. différent…tu me dit qq tu pense
J’ai pas d’état. Peu être un reboot.
- sensor:
name: Niveau global de vigilance
unique_id: niveau_global_de_vigilance
scan_interval: 3600
command: >
curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/cartevigilance/encours" -H "accept: */*" -H "apikey: apikey" | jq '{"today": .product.periods[0].timelaps.domain_ids[1].phenomenon_items | sort_by(.phenomenon_id), "tomorrow": .product.periods[1].timelaps.domain_ids[1].phenomenon_items | sort_by(.phenomenon_id)}'
value_template: "{{ value_json.today.max_color_id }} "
json_attributes:
- today
- tomorrow
Je vais voir…je le changers vers le numéro (1>4)
EDIT…pfff… mieux
- sensor:
name: meteo_france_alerts_06
scan_interval: 30000
command: >
curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/cartevigilance/encours" -H "accept: */*" -H "apikey: KEYKEYKEY" | jq '{details: {"domain_max_color_id_today": .product.periods[0].timelaps.domain_ids[68].max_color_id,"domain_max_color_id_tomorrow": .product.periods[1].timelaps.domain_ids[68].max_color_id, "update_time": .product.update_time}, "today": .product.periods[0].timelaps.domain_ids[68].phenomenon_items | sort_by(.phenomenon_id), "tomorrow": .product.periods[1].timelaps.domain_ids[68].phenomenon_items | sort_by(.phenomenon_id)}'
value_template: "{{ value_json.details.domain_max_color_id_today }}"
unique_id: meteo_france_alerts_06
json_attributes:
- details
- today
- tomorrow