Skip to content

Commit af6ed09

Browse files
authored
Update HomeData
This class is deprecated in the last API from Netatmo Most devices are in HomesData with HomeStatus
1 parent b9692c6 commit af6ed09

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

lnetatmo.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,11 @@ class HomeData:
631631
632632
Args:
633633
authData (ClientAuth): Authentication information with a working access Token
634+
home : Home name of the home where's devices are installed
634635
"""
635636
def __init__(self, authData, home=None):
637+
warnings.warn("The 'HomeData' class is deprecated'",
638+
DeprecationWarning )
636639
self.getAuthToken = authData.accessToken
637640
postParams = {
638641
"access_token" : self.getAuthToken
@@ -647,13 +650,29 @@ def __init__(self, authData, home=None):
647650
C = v.get('cameras')
648651
P = v.get('persons')
649652
S = v.get('smokedetectors')
653+
for d in self.rawData['homes'] :
654+
if home == d['name']:
655+
self.homes = d
656+
else:
657+
pass
658+
#
659+
C = self.homes['cameras']
660+
P = self.homes['persons']
661+
S = self.homes['smokedetectors']
662+
E = None
663+
# events not always in self.homes
664+
if 'events' in self.homes.keys():
650665
E = v.get('events')
651-
S or logger.warning('No smoke detector found')
652-
C or logger.warning('No Cameras found')
653-
P or logger.warning('No Persons found')
654-
E or logger.warning('No events found')
655-
if not (C or P or S or E):
656-
raise NoDevice("No device found in home %s" % k)
666+
if not S:
667+
logger.warning('No smoke detector found')
668+
if not C:
669+
logger.warning('No Cameras found')
670+
if not P:
671+
logger.warning('No Persons found')
672+
if not E:
673+
logger.warning('No events found')
674+
# if not (C or P or S or E):
675+
# raise NoDevice("No device found in home %s" % k)
657676
if S or C or P or E:
658677
self.default_home = home or list(self.homes.values())[0]['name']
659678
# Split homes data by category
@@ -680,6 +699,7 @@ def __init__(self, authData, home=None):
680699
c["home_id"] = curHome['id']
681700
for camera,e in self.events.items():
682701
self.lastEvent[camera] = e[sorted(e)[-1]]
702+
#self.default_home has no key homeId use homeName instead!
683703
if not self.cameras[self.default_home] : raise NoDevice("No camera available in default home")
684704
self.default_camera = list(self.cameras[self.default_home].values())[0]
685705
else:

0 commit comments

Comments
 (0)