From 4f280e7ba93f4f33ef087dc86b9bdefc952b130e Mon Sep 17 00:00:00 2001 From: Simone Denei <3720395+m4tto@users.noreply.github.com> Date: Sun, 19 Dec 2021 00:36:48 +0100 Subject: [PATCH 1/2] add S41/SCP White Light control --- foscam/foscam.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/foscam/foscam.py b/foscam/foscam.py index 3f6bb8c..f155412 100644 --- a/foscam/foscam.py +++ b/foscam/foscam.py @@ -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 From daabe681a1aea62fef43a0919ad23ad5093e9820 Mon Sep 17 00:00:00 2001 From: Simone Denei <3720395+m4tto@users.noreply.github.com> Date: Fri, 24 Dec 2021 11:20:51 +0100 Subject: [PATCH 2/2] add white light function testing --- tests/camtest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/camtest.py b/tests/camtest.py index 611c7d4..e152b2e 100644 --- a/tests/camtest.py +++ b/tests/camtest.py @@ -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)