Conversation
|
I linked my git@ email address to github as well, hope the cla-bot rechecks that automatically :) |
|
Hi @colinfrei, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
|
Are all the public sensors for rain? Never temperature? |
|
I use the rain sensors, which is why I added those, temperature and some others would be available as well. |
|
Ok, so where are you specifying that you get rain data or is that default? |
Danielhiversen
left a comment
There was a problem hiding this comment.
Thanks for your contribution. This will be a useful component.
I have added some comments.
You also got some comments on your documentation: home-assistant/home-assistant.io#5893 (comment)
|
|
||
|
|
||
| def calculate_average(raindata): | ||
| """Get the average value in the area.""" |
There was a problem hiding this comment.
Why not use sum(raindata.values()) / len(raindata) ?
| LAT_NE=self.lat_ne, | ||
| LON_NE=self.lon_ne, | ||
| LAT_SW=self.lat_sw, | ||
| LON_SW=self.lon_sw) |
There was a problem hiding this comment.
Add required_data_type = "rain" to make it obvious that you ask for rain data
| self._state = self.netatmo_data.data | ||
|
|
||
|
|
||
| class NetatmoPublicData(object): |
There was a problem hiding this comment.
This NetatmoPublicData class is not needed when we only support rain data
There was a problem hiding this comment.
Would it be ok to leave it since I'd expect that to expand to additional metrics soon?
There was a problem hiding this comment.
I think so. Would be nice with other sensors too.
|
|
||
| if raindata.CountStationInArea() == 0: | ||
| _LOGGER.warning('No Rain Station available in this area.') | ||
| else: |
There was a problem hiding this comment.
Use return here, and skip the else:
|
|
||
| def calculate_max(raindata): | ||
| """Get the highest value in the area.""" | ||
| key_max = max(raindata.keys(), key=(lambda k: raindata[k])) |
There was a problem hiding this comment.
Why not max(raindata.values()) ?
| raindata_live = raindata.getLive() | ||
|
|
||
| if self.calculation == 'avg': | ||
| self.data = calculate_average(raindata_live) |
There was a problem hiding this comment.
Not necessary to calculate_average as a separate function.
| if self.calculation == 'avg': | ||
| self.data = calculate_average(raindata_live) | ||
| else: | ||
| self.data = calculate_max(raindata_live) |
There was a problem hiding this comment.
Not necessary to calculate_max as a separate function.
d8b6909 to
a4f4e52
Compare
a4f4e52 to
391e8e9
Compare
| LON_NE=self.lon_ne, | ||
| LAT_SW=self.lat_sw, | ||
| LON_SW=self.lon_sw, | ||
| required_data_type = "rain") |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
|
Ah, this one would be so usefull! |
There was a problem hiding this comment.
LGTM. 🎉
Just remove the error logging line
And fix the style error: https://travis-ci.org/home-assistant/home-assistant/jobs/412315360#L565
| self._state = self.netatmo_data.data | ||
|
|
||
|
|
||
| class NetatmoPublicData(object): |
There was a problem hiding this comment.
I think so. Would be nice with other sensors too.
|
|
||
| raindata_live = raindata.getLive() | ||
|
|
||
| _LOGGER.error(raindata_live.values()) |
0ac6ee2 to
8afb891
Compare
|
Fixed :) |
| def update(self): | ||
| """Request an update from the Netatmo API.""" | ||
| import pyatmo | ||
| _LOGGER.error('Updating Netatmo data.') |
There was a problem hiding this comment.
Wrong log level. We can remove this all together.
There was a problem hiding this comment.
definitely - not sure how that sneaked in.
Fixed here: #15966
* Add a sensor for netatmo public data * A bit of cleanup before submitting pull request * Add netatmo_public file to .coveragerc, as per pull request template instructions * Fixes for tox complaining * make calculations simpler, based on review feedback * explicitly pass required_data parameter to netatmo API * remove unnecessary spaces * remove debug code * code style fix
* Add a sensor for netatmo public data * A bit of cleanup before submitting pull request * Add netatmo_public file to .coveragerc, as per pull request template instructions * Fixes for tox complaining * make calculations simpler, based on review feedback * explicitly pass required_data parameter to netatmo API * remove unnecessary spaces * remove debug code * code style fix
Description:
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5893
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices: