diff --git a/phue.py b/phue.py index a1a9f2e..27cc35a 100755 --- a/phue.py +++ b/phue.py @@ -890,7 +890,18 @@ def set_light(self, light_id, parameter, value=None, transitiontime=None): logger.debug(result) return result - + + def scan_lights(self): + if self.request('GET', '/api/' + self.username + '/lights/new')['lastscan'] != 'active': + logger.info("Scanning for new lights") + # empty POST request initialises scan + self.request('POST', '/api/' + self.username + '/lights', "") + else: + logger.info("Scan for new light requested, but there is an ongoing scan") + + def scan_lights_active(self): + return self.request('GET', '/api/' + self.username + '/lights/new')['lastscan'] == 'active' + # Sensors ##### @property @@ -1028,6 +1039,17 @@ def delete_sensor(self, sensor_id): return self.request('DELETE', '/api/' + self.username + '/sensors/' + str(sensor_id)) except: logger.debug("Unable to delete nonexistent sensor with ID {0}".format(sensor_id)) + + def scan_sensors(self): + if self.request('GET', '/api/' + self.username + '/sensors/new')['lastscan'] != 'active': + logger.info("Scanning for new sensors") + # empty POST request initialises scan + self.request('POST', '/api/' + self.username + '/sensors', "") + else: + logger.info("Scan for new sensor requested, but there is an ongoing scan") + + def scan_sensors_active(self): + return self.request('GET', '/api/' + self.username + '/sensors/new')['lastscan'] == 'active' # Groups of lights ##### @property