If you are using the home assistant « Météo France » https://www.home-assistant.io/integrations/meteo_france integration, you may be part of the unlucky locations that do not have the 1 hour rain forecast reported by the integration. This is due to a historical setting used by this integration (setting “rain_product_available”) that looks no more accurate. Several persons have requested to have this integration updated to remove the check on this setting, but there is very low listening from integration maintainers on this request.
By default the 1 hour rain forecast is stored as part of a sensor named “sensor.<city>_next_rain”. That one is refreshed every 5mn.
So the proposal of this note is to guide you to provide a workaround and to create a sensor named “sensor.<city>_next_rain_custom” until Météo France integration Maintainers handle the improvement request.
Step 1) Ensure 1 hour forecast is really available.
You have to ensure the hourly rain forecast is available on the “official” https://meteofrance.com/ web portal. Select your city and check there are accurate values for “Pluie dans l’heure” widget. If that one is not available, that means 1 hour rain forecast is not available for your location and no need to move ahead with this thread. But hopefully this is available now for almost most French cities…
Step 2) Retrieve your city details (lat & lon)
You have to use Météo France API to get parameters for your city (in fact the longitude and latitude). Météo France API makes this task easy but using this web request:
https://webservice.meteofrance.com/places?q=<CodePostal>&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
Replace the <CodePostal> by yours like city postal code (sample for Evian 74500)
Sample: https://webservice.meteofrance.com/places?q=74500&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
and copy this URL to web browner (Edge, Chrome, …). Note: in this specific case Microsoft Edge rendering is much better and will allow you to directly target the correct values for “lat” and “lon”
Replace the <lat> and <lon> of the following url with the 2 values of “lat” and “lon”, you have collected in the previous step
https://webservice.meteofrance.com/v3/rain?lat=<lat>lon=<lon>&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
in my sample:
https://webservice.meteofrance.com/v3/rain?lat=46.4004&lon=6.5906&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
then copy this URL to web browner (Edge, Chrome, …). Note: in this specific case Microsoft Edge rendering is much better
you should get out output like:
You have now to edit home assistant configuration.yaml, and add the 2 following sections related to rest_command and template
Caution: Replace ALL the <city> by you location/town, and the <lat> and <lon> by the ones retrieved on previous step
Save the configuration file, check configuration and force a reload of home assistant (all details on howto perform these activities are available on other posts).
#
#
rest_command:
#
# Meteo France - <city> Previsions de pluie a 1 heure
<city>_next_rain_rest:
url: https://webservice.meteofrance.com/v3/rain?lat=<lat>&lon=<lon>&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
method: GET
Template:
#
# MeteoFrance - <city>_next_rain
- trigger:
- platform: time_pattern
minutes: /5
- platform: homeassistant
event: start
action:
- service: rest_command.<city>_next_rain_rest
response_variable: next_rain_response
sensor:
- name: <City> Next rain Custom
unique_id: <city>_next_rain_custom
state: "{{ next_rain_response['status'] }}"
attributes:
last_evaluation: "{{ now().isoformat() }}"
forecast_time_ref: >
{%- set cancontinue = 0 -%}
{%- if next_rain_response['status'] == 200 -%}
{%- if next_rain_response['content'].update_time is defined -%}
{%- set cancontinue = 1 -%}
{%- endif -%}
{%- endif -%}
{%- if cancontinue == 1 -%}
{{ next_rain_response['content'].update_time }}
{%- else -%}
{%- if state_attr('sensor.<city>_next_rain_custom','forecast_time_ref') is none -%}
{{ now().isoformat() }}
{%- else -%}
{{ state_attr('sensor.<city>_next_rain_custom','forecast_time_ref') }}
{%- endif -%}
{%- endif -%}
1_hour_forecast: >
{# expected output: "{'5 min': 'Temps sec', '10 min': 'Pluie modérée',}" #}
{%- set cancontinue = 0 -%}
{%- if next_rain_response['status'] == 200 -%}
{%- if next_rain_response['content'].update_time is defined -%}
{%- set cancontinue = 1 -%}
{%- endif -%}
{%- endif -%}
{%- if cancontinue == 1 -%}
{%- set dref = as_datetime(next_rain_response['content'].update_time) -%}
{%- set forecasts = next_rain_response['content'].properties.forecast -%}
{%- if forecasts | count > 0 -%}
{%- set dref = as_datetime(forecasts[0].time) -%}
{%- endif -%}
{
{%- for forecast in (forecasts) -%}
{%- set d = as_datetime(forecast.time) -%}
{%- set dd = d - dref -%}
'{{ (dd.seconds / 60) | int }} min': '{{ forecast.rain_intensity_description }}',
{%- endfor -%}
}
{%- else -%}
{%- if state_attr('sensor.<city>_next_rain_custom','1_hour_forecast') is none -%}
{}
{%- else -%}
{{ state_attr('sensor.<city>_next_rain_custom','1_hour_forecast') }}
{%- endif -%}
{%- endif -%}
Check the values updated on this new sensor (every 5mn) by using the developer tools -> state and selecting the sensor “sensor.<city>_next_rain_custom”. The expected output should be similar to the following:
last_evaluation: "2024-09-16T10:35:00.261339+02:00"
forecast_time_ref: "2024-09-16T08:20:00.000Z"
1_hour_forecast:
0 min: Temps sec
5 min: Temps sec
10 min: Temps sec
15 min: Temps sec
20 min: Temps sec
25 min: Temps sec
35 min: Temps sec
45 min: Temps sec
55 min: Temps sec
Step 5) Update Meteo France lovelace with sensor.<city>_next_rain_custom
Step 6) Check for update on Meteo France integration
Sooner or later the Meteo France integration should correct the missing <city>_next_rain sensor. So check on regular basis update on this integration and when you’ll get an official <city>_next_rain, jus discard all the above 😉.
Bonjour,
merci beaucoup pour ce super tutoriel. J'ai enfin un sensor avec les prévisions de pluie, qui n'a jamais été disponible dans ma région ( 11 ).
Feedback
If you are using the home assistant « Météo France » https://www.home-assistant.io/integrations/meteo_france integration, you may be part of the unlucky locations that do not have the 1 hour rain forecast reported by the integration. This is due to a historical setting used by this integration (setting “rain_product_available”) that looks no more accurate. Several persons have requested to have this integration updated to remove the check on this setting, but there is very low listening from integration maintainers on this request. By default the 1 hour rain forecast is stored as part of a sensor named “
sensor.<city>_next_rain
”. That one is refreshed every 5mn. So the proposal of this note is to guide you to provide a workaround and to create a sensor named “sensor.<city>_next_rain_custom
” until Météo France integration Maintainers handle the improvement request.Step 1) Ensure 1 hour forecast is really available.
You have to ensure the hourly rain forecast is available on the “official” https://meteofrance.com/ web portal. Select your city and check there are accurate values for “Pluie dans l’heure” widget. If that one is not available, that means 1 hour rain forecast is not available for your location and no need to move ahead with this thread. But hopefully this is available now for almost most French cities…
Step 2) Retrieve your city details (lat & lon)
You have to use Météo France API to get parameters for your city (in fact the longitude and latitude). Météo France API makes this task easy but using this web request:
https://webservice.meteofrance.com/places?q=<CodePostal>&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
Replace the<CodePostal>
by yours like city postal code (sample for Evian 74500) Sample:https://webservice.meteofrance.com/places?q=74500&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
and copy this URL to web browner (Edge, Chrome, …). Note: in this specific case Microsoft Edge rendering is much better and will allow you to directly target the correct values for “lat” and “lon”Step 3) Confirm 1 hour rain forecast is working
Replace the
<lat>
and<lon>
of the following url with the 2 values of “lat” and “lon”, you have collected in the previous stephttps://webservice.meteofrance.com/v3/rain?lat=<lat>lon=<lon>&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
in my sample:
https://webservice.meteofrance.com/v3/rain?lat=46.4004&lon=6.5906&token=__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__
then copy this URL to web browner (Edge, Chrome, …). Note: in this specific case Microsoft Edge rendering is much better you should get out output like:Step 4) Create the
sensor.<city>_next_rain_custom
You have now to edit home assistant configuration.yaml, and add the 2 following sections related to rest_command and template Caution: Replace ALL the
<city>
by you location/town, and the<lat>
and<lon>
by the ones retrieved on previous step Save the configuration file, check configuration and force a reload of home assistant (all details on howto perform these activities are available on other posts).Check the values updated on this new sensor (every 5mn) by using the developer tools -> state and selecting the sensor “
sensor.<city>_next_rain_custom
”. The expected output should be similar to the following:Step 5) Update Meteo France lovelace with s
ensor.<city>_next_rain_custom
You can now update your Météo France Lovelace ( https://github.com/hacf-fr/lovelace-meteofrance-weather-card ) with this new sensor.
Using “show code editor” yaml editor – Of course replace
<city>
by your town/location.PS: This screenshot is taken from the dev branch of this lovelace https://github.com/hacf-fr/lovelace-meteofrance-weather-card/tree/dev
Step 6) Check for update on Meteo France integration
Sooner or later the Meteo France integration should correct the missing
<city>_next_rain sensor
. So check on regular basis update on this integration and when you’ll get an official<city>_next_rain
, jus discard all the above 😉.URL
https://www.home-assistant.io/integrations/meteo_france/
Version
2024.9.1
Additional information
No response