Skip to content

Commit 9f87b57

Browse files
committed
[Fix] Fix regression #62
1 parent 23b9167 commit 9f87b57

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

lnetatmo.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,21 @@ def modulesNamesList(self, station=None, home=None):
384384
res.append(self.stationByName(station)['module_name'])
385385
return res
386386

387-
def stationByName(self, station=None):
387+
# Both functions (byName and byStation) are here for historical reason,
388+
# considering that chances are low that a station name could be confused with a station ID,
389+
# there should be in fact a single function for getting station data
390+
391+
def getStation(self, station=None):
388392
if not station : station = self.default_station
389-
if station not in self.stations : return None
390-
return self.stations[station]
393+
if station in self.stations : return self.stations[station]
394+
if station in self.stationIds : return self.stationIds[station]
395+
return None
391396

397+
# Functions for compatibility with previous versions
398+
def stationByName(self, station=None):
399+
return self.getStation(station)
392400
def stationById(self, sid):
393-
if not sid : return self.stations[self.default_station]
394-
if sid not in self.stationIds : return None
395-
return self.stationIds[sid]
401+
return self.getStation(sid)
396402

397403
def moduleByName(self, module):
398404
for m in self.modules:

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='lnetatmo',
7-
version='3.2.1',
7+
version='3.3.0',
88
classifiers=[
99
'Development Status :: 5 - Production/Stable',
1010
'Intended Audience :: Developers',
@@ -17,7 +17,7 @@
1717
scripts=[],
1818
data_files=[],
1919
url='https://github.com/philippelt/netatmo-api-python',
20-
download_url='https://github.com/philippelt/netatmo-api-python/archive/v3.2.1.tar.gz',
20+
download_url='https://github.com/philippelt/netatmo-api-python/archive/v3.3.0.tar.gz',
2121
license='GPL V3',
2222
description='Simple API to access Netatmo weather station data from any python script.'
2323
)

usage.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ Properties, all properties are read-only unless specified:
252252
Methods :
253253

254254

255+
* **getStation** (station=None) : Find a station by it's station name or station ID
256+
* Input : Station name or ID to lookup (str)
257+
* Output : station dictionary or None
258+
255259
* **stationByName** (station=None) : Find a station by it's station name
256260
* Input : Station name to lookup (str)
257261
* Output : station dictionary or None

0 commit comments

Comments
 (0)