Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add White Light Control for S41/SCP models #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions foscam/foscam.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,45 @@ def set_infra_led_config(self, mode, callback=None):
params = {'mode': mode}
return self.execute_command('setInfraLedConfig', params, callback=callback)

def open_white_light(self, callback=None):
'''
Force open white light, set manual mode first using set_white_light_config
cmd: openWhiteLight
'''
return self.execute_command('openWhiteLight', {}, callback=callback)

def close_white_light(self, callback=None):
'''
Force close white light, set manual mode first using set_white_light_config
cmd: closeWhiteLight
'''
return self.execute_command('closeWhiteLight', callback=callback)

def get_white_light_config(self, callback=None):
'''
Get White Light configuration
cmd: getWhiteLightConfig
'''
return self.execute_command('getWhiteLightConfig', callback=callback)

def set_white_light_config(self, lightmode, callback=None):
'''
Set White Light configuration
cmd: setWhiteLightConfig
Lightmode(0,1): 0=Auto mode, 1=?, 2=Manual mode
'''
params = {'Lightmode': lightmode}
return self.execute_command('setWhiteLightConfig', params, callback=callback)

def set_night_light_state(self, state, callback=None):
'''
Set Night Light state
cmd: setNightLightState
state(0,1): 0=Off, 1=On
'''
params = {'state': state}
return self.execute_command('setNightLightState', params, callback=callback)

def get_product_all_info(self, callback=None):
'''
Get camera information
Expand Down
16 changes: 16 additions & 0 deletions tests/camtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,22 @@ def test_set_infra_led_config(self):
rc, args = self.foscam.set_infra_led_config(1)
self.assertEqual(rc, 0)

def test_open_white_light(self):
rc, args = self.foscam.open_white_light()
self.assertEqual(rc, 0)

def test_close_white_light(self):
rc, args = self.foscam.close_white_light()
self.assertEqual(rc, 0)

def test_get_white_light_config(self):
rc, args = self.foscam.get_white_light_config()
self.assertEqual(rc, 0)

def test_set_white_light_config(self):
rc, args = self.foscam.set_white_light_config(2)
self.assertEqual(rc, 0)

def test_get_product_all_info(self):
rc, args = self.foscam.get_product_all_info()
self.assertEqual(rc, 0)
Expand Down