Skip to content

Commit 6b687db

Browse files
committed
[Fix] #44 wrong default station selected for multi-homes setup
1 parent 8a76bd4 commit 6b687db

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lnetatmo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ def __init__(self, authData, home=None, station=None):
320320
self.stations = { d['station_name'] : d for d in self.rawData }
321321
self.homes = { d['home_name'] : d["station_name"] for d in self.rawData }
322322
# Keeping the old behavior for default station name
323-
if station and station not in self.stations: raise NoDevice("No station with name %s" % station)
324-
self.default_station = station or list(self.stations.keys())[0]
325323
if home and home not in self.homes : raise NoHome("No home with name %s" % home)
326324
self.default_home = home or list(self.homes.keys())[0]
325+
if station and station not in self.stations: raise NoDevice("No station with name %s" % station)
326+
self.default_station = station or [v["station_name"] for k,v in self.stations.items() if v["home_name"] == self.default_home][0]
327327
self.modules = dict()
328328
self.default_station_data = self.stationByName(self.default_station)
329329
if 'modules' in self.default_station_data:

0 commit comments

Comments
 (0)