Skip to content

Commit bcf1449

Browse files
authored
Merge pull request #16 from viswa-swami/check_for_error_before_processing
Check if get was successful before trying to set some config.
2 parents d76f5b5 + aa1d019 commit bcf1449

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

foscam/foscam.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,20 +613,25 @@ def set_motion_detection(self, enabled=1):
613613
Get the current config and set the motion detection on or off
614614
'''
615615
result, current_config = self.get_motion_detect_config()
616+
if result != FOSCAM_SUCCESS:
617+
return result
616618
current_config['isEnable'] = enabled
617619
self.set_motion_detect_config(current_config)
620+
return FOSCAM_SUCCESS
618621

619622
def enable_motion_detection(self):
620623
'''
621624
Enable motion detection
622625
'''
623-
self.set_motion_detection(1)
626+
result = self.set_motion_detection(1)
627+
return result
624628

625629
def disable_motion_detection(self):
626630
'''
627631
disable motion detection
628632
'''
629-
self.set_motion_detection(0)
633+
result = self.set_motion_detection(0)
634+
return result
630635

631636
def get_alarm_record_config(self, callback=None):
632637
'''

0 commit comments

Comments
 (0)