still it would be wise to make it not hardcoded.
maybe i just want to update every hour for network reasons? or every 30 minutes?
you could always state in the documentation that setting below 5 min is useless or set it default to 5 min and prove if the setting is above 5 or not.
another thing:
wouldnt it make more sense to create 2 sensors out of it? instead of 1 sensor and the other part as an atrribute?
and does the sensor give the total or the average as main value?
@ReneTode
Valid reasons for making it configurable. will look in to it this weekend. shouldn’t be that hard.
The default it is the calculated average within the specified timeframe. (update time sensor + timeframe value).
I’m not great with math, but the totals is the calculated total of the mm/h per 10 minutes within the timeframe. I’m not sure if this qualifies as a true ‘total’ for the specified timeframe ?
You can break out the attribute in a separate sensor by using a template sensor.
first you calculate the mm/h on time 1,2,3,4,5,…
then you just total those figures.
but the figure is there for only 5 minutes, then you get another figure.
so the right calculation would be
totalrain = totalrain + (float(data[key])/12)
that way you calculate the amount for 5 minutes (hour/12) and total that for the amount off time you want to calculate it.
but maybe a better way would be to calculate the average for the set time first and then you have the average mm/h
when you have that you can calculate the average per second (average/3600)
then you multiply that with the amount of set seconds.
even then you must make sure the user sets an amount of time which is a mutiplication from 5 min, because if the timeframe is 9 minutes the calculation would be wrong.
so in stead off the setting in seconds in HA you could better give the option x times 5 minutes.
the sensor gives average. so only if you want the total (for the chosen amount of time), which is given when you click on the sensor, to be accurate you have to include it.
you can also divide the amount behind total with 12 in your mind
Looking cool and works pretty perfectly. Has anybody found how to capture the image/map to show in HASS? Right now I am using one from freesat, but I would prefer the one from Buienradar.
@koen01 I know I will be able to add retrieving more forecast data from buienradar; since buienradar will give me:
min temp and max temp (I now calculate an average temp per day)
min and max rain (in mm)
chance for sub
chance for rain
wind direction
windforce (Bft)
However, it will require a change into the generic weather component from Homeassistant, since it currently expects only the temperature in the forecasted data…
Ok. I meant using the implementation I use could give you pricipitation data for the exact GPS location, not the nearest Buienradar station.
If the forecast is not possible than then current precipitation for the exact GPS location could be useful for someone?
I use the data that powers the pricipitation map shown at Buienradar.nl
Sorry; I thought you wanted to add this data into the weathercomponent…
I now see, you use a sensor to show current precipitation (mm/h) and as attributes additional info, such as average and total…
I also have added a sensor type for precipitation, but that now uses, as you said, the forecast for the selected weatherstation, not for the exact gps location…
Looking at your code, it seems that you are using a different source and are looking ahead in time to determine the amount of total and average rain expected to fall, is that correct?
Is that what you meant with your initial question “maybe you can include the precipitation forecast data too?”
That would be a sensor type of (for example) ‘expected_rain’ …
@mjj4791 Tried adding your now released weather module today, but it throws quite a few exceptions:
ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step
result = next(coro)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 368, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 202, in async_add_entity
object_id = entity.name or DEVICE_DEFAULT_NAME
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/weather/buienradar.py”, line 77, in name
return self._stationname or ‘BR {}’.format(self._data.stationname
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/buienradar.py”, line 269, in stationname
from buienradar.buienradar import STATIONNAME
ImportError: No module named ‘buienradar’
ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step
result = next(coro)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/buienradar.py”, line 232, in async_update
from buienradar.buienradar import (parse_data, CONTENT,
ImportError: No module named ‘buienradar’
Any ideas?
(also, the documentation says it is introduced in version 0.44 and therefor also doesn’t show up in the recently added modules list)
edit:
I’ve now tried out the sensor version, which doesn’t give any exceptions (yay!), but also doesn’t give any data…
Could this have anything to do with the fact that I had this as a custom component before adding this (made sure to remove it before adding, but maybe the naming conflict is still stuck somewhere?)