MeteoFrance API

Hi,
I’m trying to use MeteoFrance APi to receive weather alert.
I create a command_line.yaml

- sensor:
    name: "Météo France alertes 80"
    unique_id: meteo_france_alertes_80
    scan_interval: 10800
    command: >
      curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/cartevigilance/encours' \ -H 'accept: */*' \ -H 'apikey: MyAPI" | jq '{details: {"domain_max_color_id_today": .product.periods[0].timelaps.domain_ids[78].max_color_id,"domain_max_color_id_tomorrow": .product.periods[1].timelaps.domain_ids[78].max_color_id, "update_time": .product.update_time}, "today": .product.periods[0].timelaps.domain_ids[78].phenomenon_items | sort_by(.phenomenon_id), "tomorrow": .product.periods[1].timelaps.domain_ids[78].phenomenon_items | sort_by(.phenomenon_id)}'
    value_template: " {{ value_json.details.domain_max_color_id_today }} "
    json_attributes:
        - details
        - today
        - tomorrow

- sensor:
    name: "Météo France alertes image today"
    unique_id: meteo_france_alertes_image_today
    scan_interval: 14400
    command: >
      curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/vignettenationale-J/encours" -H "accept: */*" -H "apikey: MyAPI" > ./www/image/meteo_france_alertes_today.jpg
    value_template: "mf_alerte_today"

- sensor:
    name: "Météo France alertes image tomorrow"
    unique_id: meteo_france_alertes_image_tomorrow
    scan_interval: 14400
    command: >
      curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/vignettenationale-J1/encours" -H "accept: */*" -H "apikey: MyAPI" > ./www/image/meteo_france_alertes_tomorrow.jpg
    value_template: "mf_alerte_tomorrow"

An automation to update sensor :

- id: '1714581531030'
  alias: Alerte Météo actualisation
  description: ''
  trigger:
  - platform: homeassistant
    event: start
  - platform: time_pattern
    hours: /6
  - platform: time
    at: 06:30:00
  - platform: time
    at: '16:30:00'
  condition: []
  action:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: sensor.meteo_france_alertes_80
  - 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
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id:
      - camera.mf_alerte_today
      - camera.mf_alerte_tomorrow
  mode: single

And the cameras.yaml

- platform: local_file
  name: MF_alerte_today
  file_path: \local\image\meteo_france_alertes_today.jpg
    
- platform: local_file
  name: MF_alerte_tomorrow
  file_path: \local\image\meteo_france_alertes_tomorrow.jpg

Also my configuration.yaml

#Photo MétéoFrance pour la page Weather
camera:
- platform: local_file
  name: MF_alerte_today
  file_path: /config/www/image/meteo_france_alertes_today.jpg
    
- platform: local_file
  name: MF_alerte_tomorrow
  file_path: /config/www/image/meteo_france_alertes_tomorrow.jpg

I create the api like that :



But my sensor.meteo is always empty

If everything working well my sensor was informations like that

The log :

Logger: homeassistant.components.command_line
Source: components/command_line/sensor.py:155
integration: Command Line (documentation, issues)
First occurred: 10:44:03 AM (2 occurrences)
Last logged: 10:44:20 AM

Empty reply found when expecting JSON data

Thanks for your help.

Don’t succeed to solve my json empty data.

This one is notoriusly unreliable…so sometimes it works and sometimes not…during the day I have multiple drop-out when running hourly

And you made a typo by mixing " and ’

curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/cartevigilance/encours" -H 'accept: */*' \ -H 'apikey: MyAPI'

The typo is solved.

- sensor:
    name: "Météo France alertes 80"
    unique_id: meteo_france_alertes_80
    scan_interval: 10800
    command: >
      curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/cartevigilance/encours" -H "accept: */*" -H "apikey: MyAPI" | jq "{details: {"domain_max_color_id_today": .product.periods[0].timelaps.domain_ids[78].max_color_id,"domain_max_color_id_tomorrow": .product.periods[1].timelaps.domain_ids[78].max_color_id, "update_time": .product.update_time}, "today": .product.periods[0].timelaps.domain_ids[78].phenomenon_items | sort_by(.phenomenon_id), "tomorrow": .product.periods[1].timelaps.domain_ids[78].phenomenon_items | sort_by(.phenomenon_id)}"
    value_template: " {{ value_json.details.domain_max_color_id_today }} "
    json_attributes:
        - details
        - today
        - tomorrow

- sensor:
    name: "Météo France alertes image today"
    unique_id: meteo_france_alertes_image_today
    scan_interval: 14400
    command: >
      curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/vignettenationale-J/encours" -H "accept: */*" -H "apikey: MyAPI" > ./www/image/meteo_france_alertes_today.jpg
    value_template: "mf_alerte_today"

- sensor:
    name: "Météo France alertes image tomorrow"
    unique_id: meteo_france_alertes_image_tomorrow
    scan_interval: 14400
    command: >
      curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/vignettenationale-J1/encours" -H "accept: */*" -H "apikey: MyAPI" > ./www/image/meteo_france_alertes_tomorrow.jpg
    value_template: "mf_alerte_tomorrow"

But still the issue

Logger: homeassistant.components.command_line
Source: components/command_line/sensor.py:155
integration: Command Line (documentation, issues)
First occurred: 12:05:07 PM (4 occurrences)
Last logged: 1:36:09 PM

Empty reply found when expecting JSON data

Sometimes I’ve the picture who is update sometimes no. Same for the informations.

As per my earlier comments…you will find the same on hacf.fr