-
-
Notifications
You must be signed in to change notification settings - Fork 28.6k
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
Bom weather current component #3370
Conversation
Looks good. Can merge when linting issues addressed 👍 |
Support for bom.gov.au current condition weather service. | ||
|
||
For more details about this platform, please refer to the documentation at | ||
https://home-assistant.io/components/sensor.bom_weather_current |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an additional /
at the end of the URL.
import logging | ||
import requests | ||
import voluptuous as vol | ||
import datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please update the ordering of the imports according PEP8?
CONF_ZONE_ID = 'zone_id' | ||
CONF_WMO_ID = 'wmo_id' | ||
|
||
MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=60) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why running every minute when you have to wait at least 35 minutes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bom data updates at the hour and half hour. It then takes about 4 to 7 minutes for the information to propagate to the accessible api.
The sensor runs every minute until it gets the data. Then using the bom time-stamp of the last data it has received it waits 35 min before hitting the bom api again every minute until it gets new data.
The aim of this is to not hit the bom api for the 35min that there is no new data. If this works as intended there should only be a few api data requests every half hour period.
If i just make the delay 30min then if you start HA at 10min before the hour then you will always receive your data 20min late.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are talking about weather data. Usually it doesn't matter if there is a delay. It's your call and it looks that you spent some thoughs on this.
'cloud_type_id': ['Cloud Type ID', None], | ||
'cloud_type': ['Cloud Type', None], | ||
'delta_t': ['Delta Temp C', TEMP_CELSIUS], | ||
'gust_kmh': ['Wind Gust kmh', 'kmh'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
km/h
to be in alignment with the other platforms.
'gust_kt': ['Wind Gust kt', 'kt'], | ||
'air_temp': ['Air Temp C', TEMP_CELSIUS], | ||
'dewpt': ['Dew Point C', TEMP_CELSIUS], | ||
'press': ['Pressure mb', 'mb'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other weather platforms use the unit mbar
.
'vis_km': ['Visability km', 'km'], | ||
'weather': ['Weather', None], | ||
'wind_dir': ['Wind Direction', None], | ||
'wind_spd_kmh': ['Wind Speed kmh', 'kmh'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
km/h
dito
def _build_url(self): | ||
url = _RESOURCE.format(self._zone_id, self._zone_id, self._wmo_id) | ||
_LOGGER.info("BOM url {}".format(url)) | ||
return url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a method to build an URL seems to be a bit overkill as you only using this once. Just an observation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so too. This process of building the url was borrowed from another component as I have tried to used what others are doing in components to keep the style in line with the project .
I would also suggest to rename the platform to |
I will implement those changes when I get a chance. I will unlikely get to this for a week or so though. Also I haven't setup my dev platform with tox yet, hence why i haven't done all the dev checks yet. |
- fixed order of imports - changes some of the units to be standardised
…om_weather_current
Made those suggested changes and fixed the linting issues. Not sure how to fix the failed coverage/coveralls check though. |
@@ -209,6 +209,7 @@ omit = | |||
homeassistant/components/scene/hunterdouglas_powerview.py | |||
homeassistant/components/sensor/arest.py | |||
homeassistant/components/sensor/bitcoin.py | |||
homeassistant/components/sensor/bom_weather_current.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs an update as well then coveralls will be fine.
🐦 |
Description:
The Bureau of Meteorology (BOM) Australia is the most accurate source of weather information in Australia.
The
bom_weather_current
platform allows you to get the current weather conditions from the Bureau of Meteorology (BOM) Australia.Related issue (if applicable): fixes #
none known.
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#
home-assistant/home-assistant.io#932
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If code communicates with devices, web services, or a:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.