Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API key for meteoFranceAPI does not give actual phenomenons #627

Open
theodooooo opened this issue Jun 8, 2023 · 7 comments
Open

API key for meteoFranceAPI does not give actual phenomenons #627

theodooooo opened this issue Jun 8, 2023 · 7 comments

Comments

@theodooooo
Copy link

theodooooo commented Jun 8, 2023

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I had a problem to work with meteofrance-api because the API key doesn't give result of phenomenons in the function : get_warning_current_phenomenoms .
Describe the solution you'd like
A clear and concise description of what you want to happen.

  • Adding the possibility to easily change the API key and API url,
  • (if possible) Adding a new default APIkey that gives actual phenomenons with the function in the file client.py get_warning_current_phenomenoms
    Describe alternatives you've considered
    A clear and concise description of any alternative solutions or features you've considered.
    There's no real alternatives except maybe contacting meteo france concerning the api.
    Additional context
    Add any other context or screenshots about the feature request here.
@pzim-devdata
Copy link

I have the same problem :
alert=client.get_warning_full(domain="75")
alert.end_validity_time
1680667200 --> Wednesday, April 5, 2023 4:00:00 GMT
alert.update_time
1680595200 --> Tuesday, April 4, 2023 8:00:00 GMT

And today is June 12, 2023

@Nardol
Copy link

Nardol commented Jun 17, 2023

Look like API have changed, see home-assistant/core#92197 (comment)
It also breaks météo France Home Assistant integration.

@jpty
Copy link

jpty commented Jul 8, 2023

The Meteo France archives site can also be used to get vigilances:
http://storage.gra.cloud.ovh.net/v1/AUTH_555bdc85997f4552914346d4550c421e/gra-vigi6-archive_public/2023/07/08/
for today. Data is in the API format.
It was announced here : https://donneespubliques.meteofrance.fr/?fond=produit&id_produit=305&id_rubrique=50

@bsegault
Copy link

bsegault commented Aug 2, 2023

I'd be willing to take a look at using the API v2 if no one is actually working on it.

I'll update this thread once I start to have something. Let me know if you have any other info or suggestions.

For now, I guess the first question is how to properly handle the token generation if it needs an account to be regularly re-generated...
I don't think that's an issue to request user credential from this library/API. But I don't know about the HA integration, I've never done it, so it would take me a while...

@pzim-devdata
Copy link

pzim-devdata commented Aug 2, 2023

Here is my script in Bash :

  1. Go there :https://portail-api.meteofrance.fr/devportal --> Application to make a OAuth2 Key token
  2. Use your OAuth2 key :
    key="put_your_OAUth2_key_here"
    get_token=$(curl -k -X POST https://portail-api.meteofrance.fr/token -d "grant_type=client_credentials" -H "Authorization: Basic $key")
  3. Read token :
    IFS='"' read -ra token <<< "$get_token"
    ${token[3]}
  4. Get vigilance :
    curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H "accept: /" -H "Authorization: Bearer ${token[3]}"

Example for "Eure-et-loir" :

department=28
key="put_your_OAUth2_key_here"

get_token=$(curl -k -X POST https://portail-api.meteofrance.fr/token -d "grant_type=client_credentials" -H "Authorization: Basic $key")
IFS='"' read -ra token <<< "$get_token"
${token[3]}

title=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}" | jq --arg dep "$department" '.product.text_bloc_items[] | select(.domain_id==$dep).bloc_title')

dpt=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}" | jq --arg dep "$department" '.product.text_bloc_items[] | select(.domain_id==$dep).domain_name')

Risk :
a=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}" | jq --arg dep "$department" '.product.text_bloc_items[] | select(.domain_id==$dep) | .bloc_items[].text_items[].term_items[].risk_name')

Text : 
b=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}" | jq --arg dep "$department" '.product.text_bloc_items[] | select(.domain_id==$dep) | .bloc_items[].text_items[].term_items[].subdivision_text[].text[]')

Get a notification

#!/bin/bash
department=28
key="xxxxxxxxxxxxxxxxxxxxxxxxxx"
get_token=$(curl -k -X POST https://portail-api.meteofrance.fr/token -d "grant_type=client_credentials" -H "Authorization: Basic $key")

IFS='"' read -ra token <<< "$get_token"

title=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}" | jq --arg dep "$department" '.product.text_bloc_items[] | select(.domain_id==$dep).bloc_title')

dpt=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}" | jq --arg dep "$department" '.product.text_bloc_items[] | select(.domain_id==$dep).domain_name')

a=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}" | jq --arg dep "$department" '.product.text_bloc_items[] | select(.domain_id==$dep) | .bloc_items[].text_items[].term_items[].risk_name')

b=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}" | jq --arg dep "$department" '.product.text_bloc_items[] | select(.domain_id==$dep) | .bloc_items[].text_items[].term_items[].subdivision_text[].text[]')

#c=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}"| jq '.product.text_bloc_items[25].bloc_items[1].text_items[0].term_items[0].subdivision_text[0].text')

#d=$(curl -X GET "https://public-api.meteofrance.fr/public/DPVigilance/v1/textesvigilance/encours" -H  "accept: */*" -H  "Authorization: Bearer ${token[3]}"| jq '.product.text_bloc_items[25].bloc_items[2].text_items[0].term_items[0].subdivision_text[0].text')

IFS=',' str="$(echo -e "\nVIGILANCE POUR AUJOURD'HUI : \n\nRisque : "${a[@]} '\n'${b[@]})"
str=${str//[/}
str=${str//]/}
str=${str/ /  /}
str=${str//'"'/}
str=${str//null/}
str=${str//$'\n\n\n'/}
str=${str//$'. '/$'.\n\n'}

titre="$(echo $title en $dpt)"
titre=${titre//'"'/}
titre=${titre//'*'/}
titre=${titre//$'\n'/}

if [[ ( -z "${a[@]}" || "${a[@]}" == "null" ) && ( -z "${b[@]}" || "${b[@]}" == "null" ) ]]; then
    str="Pas de vigilance aujourd'hui"
fi


zenity --info --title "$titre" --text $str --icon-name weather-severe-alert-symbolic --ok-label "C'est bon, merci :-)"

@Quentame
Copy link
Member

Does using API v3 is solving the issue ?
#680

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
@jpty @Nardol @bsegault @Quentame @theodooooo @pzim-devdata and others