@@ -631,8 +631,11 @@ class HomeData:
631
631
632
632
Args:
633
633
authData (ClientAuth): Authentication information with a working access Token
634
+ home : Home name of the home where's devices are installed
634
635
"""
635
636
def __init__ (self , authData , home = None ):
637
+ warnings .warn ("The 'HomeData' class is deprecated'" ,
638
+ DeprecationWarning )
636
639
self .getAuthToken = authData .accessToken
637
640
postParams = {
638
641
"access_token" : self .getAuthToken
@@ -647,13 +650,29 @@ def __init__(self, authData, home=None):
647
650
C = v .get ('cameras' )
648
651
P = v .get ('persons' )
649
652
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 ():
650
665
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)
657
676
if S or C or P or E :
658
677
self .default_home = home or list (self .homes .values ())[0 ]['name' ]
659
678
# Split homes data by category
@@ -680,6 +699,7 @@ def __init__(self, authData, home=None):
680
699
c ["home_id" ] = curHome ['id' ]
681
700
for camera ,e in self .events .items ():
682
701
self .lastEvent [camera ] = e [sorted (e )[- 1 ]]
702
+ #self.default_home has no key homeId use homeName instead!
683
703
if not self .cameras [self .default_home ] : raise NoDevice ("No camera available in default home" )
684
704
self .default_camera = list (self .cameras [self .default_home ].values ())[0 ]
685
705
else :
0 commit comments