pyunifi
pyunifi copied to clipboard
Change Password Function
Maybe something like this, probably add private 'put' function. Possibly call another function, as you can change anything with the put. Was in a rush, did this - much thanks much for your project.
def set_wlan_pass(self, ssid, key):
"""Changes the password for a given
ssid. Daniel ToDo: Put method. """
for wlan in self._api_read('list/wlanconf'):
if wlan['name'] == ssid:
wlan_id = wlan['_id']
wlan_settings = {}
wlan_settings["x_passphrase"] = key
params = json.dumps(wlan_settings)
url = 'rest/wlanconf/' + wlan_id
r = self.session.put(self._api_url() + url,
params)
if r.status_code is not 200:
raise APIError("Login failed - status code: %i" %
r.status_code)
return
Commented on the Pull Request.