24h precipitation forecast / 24u buienradar buienalarm

and it’s working again! :wink:

After step 2 of the configuration my HA displays a sensor for buienradar, but not for buienalarm. I copied the code from the post and added coordinates. What can be the problem? This is my code
(replaced exact coordinates with .xx)

command_line:
  - sensor:
      name: weather_buienalarm_minutes
      command: python3 -c "import requests; dataRequest = requests.get('https://cdn.buienalarm.nl/api/4.0/nowcast/timeseries/<53.xx>/<6.xx>',headers={'Cache-Control':'no-cache'}).text; dataRequest = dataRequest.replace('\r\n',' '); print(dataRequest);"
      unique_id: 1704013893
      json_attributes:
        - data
      value_template: "last_changed: {{states.sensor.weather_buienalarm_minutes.last_changed | default(now())}}"
      scan_interval: 150
      
command_line:
  - sensor:
      name: weather_buienradar_minutes
      command: python3 -c "import requests; response = requests.get('https://graphdata.buienradar.nl/3.0/forecast/geo/RainHistoryForecast?lat=<53.xxx>&lon=<6.xxx>',headers={'Cache-Control':'no-cache'}).text; data = '{\"data\":'+response.replace('\r\n',' ')+'}'; print(data);"
      unique_id: 1704016555
      json_attributes:
        - data
      value_template: "last_changed: {{states.sensor.weather_buienradar_minutes.last_changed | default(now())}}"
      scan_interval: 150

Is it exactly like this in your config? Then it’s a basic YAML syntax error.
These YAML files are not read by HA top to bottom; they are arrays of information that are processed.
“command_line:” is the name of a variable. So the second time that you define this variable it will overwrite the first.
Remove the second “command_line:” line, be careful to not change the indentation of “- sensor:”, and it should work.

Kind regards,
- Ingrid

That looks like it helped creating the sensor, which is now visible.
Though the state of the sensor remains unknown, and the graph is stuck on loading.
Would i need to wait for rain for it to change?

I don’t know if this should work but in my browser i opened the url (with xx being my exact coordinates) https://cdn.buienalarm.nl/api/4.0/nowcast/timeseries/<53.xx>/<6.xx>
it shows: Error 503 Service Unavailable

Edit:
I removed the <> from the URL, also in the sensor configuration. this gives me a detailed rain precipation
https://cdn.buienalarm.nl/api/4.0/nowcast/timeseries/53.xx/6.xx

Still my sensor state remains unknown…

Did you check the logs for errors? Because I need some information to be able to help you.

A possibility is a timeout error? Search your log for “cdn.buienalarm.nl”. Do you see anything like: Timeout for command: python3 -c "import requests; response = requests.get('https://cdn.buienalarm.nl/api/4.0/nowcast/timeseries

The default timeout for a command_line sensor is 15 seconds. To increase it add “command_timeout” (see Command line - Home Assistant).

It should look like this:

  - sensor:
      name: weather_buienalarm_minutes
      command: <your-command>
      unique_id: <your-id>
      json_attributes:
        - data
      value_template: "last_changed: {{states.sensor.weather_buienalarm_minutes.last_changed | default(now())}}"
      scan_interval: 150
      command_timeout: 60

Hope this helps.
Kind regards,
- Ingrid

There is no error in the log.
I changed the default time out. It did not right away, but it looks like the sensor will retrieve data from now on.

The graph says it was loading for a long time.

Now it shows the line only for buienalarm…
Might show both when there is rain? or is this already a sign of an error.

So I found the issue. Which was that I left the <> in the sensor command line of the sensor, where my coordinates should be. Now the graph shows both sensors :slight_smile:

1 Like

Does the buienalarm 2h sensor still work? I got the 24h graph working for both but the 2h one only works for buienradar for me. when I add buienalarm it keeps loading. Thanks!

command_line:
  - sensor:
      name: weather_buienalarm_minutes
      unique_id: weather_buienalarm_minutes
      command: >
        python3 -c "import requests;
        url='https://imn-rust-lb.infoplaza.io/v4/nowcast/ba/timeseries/<53.xx>/<6.xx>';
        headers={'User-Agent':'Meteoplaza-API-iOS/1.0','Cache-Control':'no-cache'};
        r=requests.get(url,headers=headers,timeout=10);
        txt=r.text.replace('\n',' ').replace('\r',' ');
        print(txt);"
      json_attributes:
        - data
        - daypart
        - nowcastmessage
        - summary
      value_template: >
        last_changed: {{ now() }}
      scan_interval: 150      
1 Like

Hi, thanks for the heads up.

I will check the source @RonOnline suggested. However, do not include a ‘<’ or a ‘>’ in your url as he suggested. This will cause errors.
When I have working source I will update the original post.
Kind regards,
- Ingrid

that is ofcourse just a placeholder :slight_smile:

This wasn’t clear for previous users. There are many users who are just starting off and are not yet familiar with these requests.
It would be clearer to replace it with a placeholder, e.g. <latitude>, and provide instructions on how to substitute it, rather than simply pasting it without any explanation.

Kind regards,
- Ingrid

You are right! Sorry for that! :slight_smile:

@RonOnline: thanks for the data source, I updated the original post.
Kind regards,
- Ingrid

1 Like

I’m getting no temperature data from Buienradar since 12:05 pm yesterday (weather station
Lopik-Cabauw (6348)). Is it a general failure or do I have to look for a local issue?

Did you input the request URL in a browser windos to check the output?
The sensor has been working fine in my install.

Kind regards,
- Ingrid