Buienalarm custom_component

Since I find buienalarm the most reliable way to predict rain where I live.
I’ve created a packet to get data from buienalarm https://github.com/gieljnssns/buienalarm, and a custom component to use it in Home-assistant https://github.com/gieljnssns/My-Hassio-config/tree/master/config/custom_components/buienalarm https://github.com/gieljnssns/buienalarm-sensor-homeassistant

sensor:
  - platform: buienalarm
    timeframe: 15
    name: buienalarm
    monitored_conditions:
      - temperature
      - precipitation
      - precipitation_forecast_average
      - precipitation_forecast_total
      - next_rain_forecast

Your sensors default name will be sensor.ba_{monitored_condition}
You can provide a timeframe: Minutes to look ahead for precipitation forecast (min: 5 / max: 120). - Default value: 60

values for next_rain_forecast can be:

  • -1 No rain forecast withing timeframe
  • 0 It is currently raining
  • N Rain is forecast within N minutes
5 Likes

Thanks Giel, looking good! I’m now waiting for some rain to check the accuracy :wink:

Do you know about this: https://github.com/koen01/pybuienradar

This one pulls rain data from the buienradar website as it is used as input for the rain-graph shown on the buienradar localized website. Unfortunately there is not good way to display the info in a graph, at least not that I could find. Everything is made with history-graphs in mind.
But I’m only a beginner. That’s why I went with showing the buienalarm-graphs in a Panel Iframe :slight_smile:

hi, tried your custom, works great

but if i do a reboot of my HassOS , i get errror below
if i then do a restart only of hassio, no error anymore, and working

2019-06-12 12:20:18 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform buienalarm
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/buienalarm/sensor.py", line 72, in setup_platform
    dev.append(BaSensor(b, sensor, timeframe, config.get(CONF_NAME)))
  File "/config/custom_components/buienalarm/sensor.py", line 89, in __init__
    self.update()
  File "/config/custom_components/buienalarm/sensor.py", line 117, in update
    self._state = self.buienalarm.get_precipitation_now()
  File "/usr/local/lib/python3.7/site-packages/buienalarm/pybuienalarm.py", line 45, in get_precipitation_now
    return self.precipitation[1]
KeyError: 1

Hello,
is there a way to specify multiple locations? I’d love to get that information for my work and my home and they are not in the same region at all.

I never tried…
You can try

  - platform: buienalarm
    timeframe: 30
    name: home
    monitored_conditions:
      - temperature
      - precipitation
      - precipitation_forecast_average
      - precipitation_forecast_total

  - platform: buienalarm
    timeframe: 30
    name: work
    latitude: 6547556
    longitude: 765765858
    monitored_conditions:
      - temperature
      - precipitation
      - precipitation_forecast_average
      - precipitation_forecast_total

Hello Giel
I’m new to this all, but i’m running homeassistant in Docker, i can’t figure out how to add buienalarm to the container.
Buienradar is already added but i prefer to use buienalarm.
I suppose i need to install it somehow with a pip command.

Nope, you have to make a custom_components folder in your config folder (where your configuration.yaml lives)
In that folder make a folder buienalarm, in there you have to place those 4 files.

Install trough HACS

Then add to your configuration.yaml

sensor:
  - platform: buienalarm
    timeframe: 15
    name: buienalarm
    monitored_conditions:
      - temperature
      - precipitation
      - precipitation_forecast_average
      - precipitation_forecast_total
      - next_rain_forecast

Should it be added under the weather component in configuration.yaml?
If yes: I’m still doing something wrong then.

I have placed the four files in a custom_components/buienalarm folder, but I get a “Platform not found: weather.buienalarm” error.

Hello Giel

Thank you for that fast reply, the folder creation was easy done, but now the stupid question, i don’t now how to download those files from your link (sorry)

In de meantime i found out how to add them, but i do have an error when cheking the configuration file
image

Maybe this part of the installation is confusing:

  - platform: buienalarm
    timeframe: 30
    # name: buienalarm
    monitored_conditions:
      - temperature
      - precipitation
      - precipitation_forecast_average
      - precipitation_forecast_total

This must be put under the sensor heading, like this:

sensor:
...
...
  - platform: buienalarm
    timeframe: 30
    # name: buienalarm
    monitored_conditions:
      - temperature
      - precipitation
      - precipitation_forecast_average
      - precipitation_forecast_total

It’s done like this, but like you can read, it’s telling me that the integration of buienalarm is not found, maybe it’s because it runs in docker?

That looks good.

But, your directory structure is wrong.
The buienalarm-directory must be inside another directory with the name custom_components
On your system: homeassistance/custom_components/buienalarm

1 Like

Hi Bouwew

Thank you for helping me out, it does work, seems to me i have a lot to learn :slight_smile:

You are welcome!
I was you, 6 months ago :smile:

The next item that could do the trick is this one…
Maybe you already noticed. it’s realy intresting.

When the new Cast functionality is out you could just cast a lovelace screen to a TV, having all those items you suggest on that lovelace screen.

Perfect, works just as it should

Hi Giel,

I tried buienalarm and although I like it, it showed up in pihole generating 46000 request in the last 24 hours. That is by far the absolute highest position in my network. The next domain on the list has “only” 11000. Is there something that can be done?

Thanks.

Add this to your configuration to have it check every 5 minutes

scan_interval: 300

Within a few weeks I normally have some time to optimize all this a bit