nickovs / unificontrol

A high-level Python interface to the Unifi controller software
Apache License 2.0
96 stars 41 forks source link

Changing device settings with set_device_settings_base API #6

Closed mbharatheesha closed 4 years ago

mbharatheesha commented 4 years ago

Hi there,

Many thanks for the creation of these APIs to work with UNIFI devices. Helps a lot with scripting.

I am trying to understand the use of set_device_settings_base API because I want to change the name property of a device in a site. For example, when I configure the device via the Cloud UI, I can add a device alias in the General tab under device configs.

Then, when I do:

print(client.list_devices_basic())

I see, the alias I added through the Cloud UI appear in the output. Here is an example of before and after changing the device name on CloudUI. Before changing alias in device Config tab:

[{'mac': '00:00:00:00:00:00', 'state': 1, 'adopted': True, 'disabled': False, 'type': 'usw', 'model': 'US24'}]

After changing alias in device Config tab:

[{'mac': '00:00:00:00:00:00', 'state': 1, 'adopted': True, 'disabled': False, 'type': 'usw', 'model': 'US24', 'name': 'NEW_UNIFI_SWITCH1'}]

I intend to change the name field or add a name if the field does not exist. I think set_device_settings_base seems to be the correct API for it, but I don't seem to be able to figure out the settings payload. I would really appreciate some help here.

Thanks!

mbharatheesha commented 4 years ago

Figured this out a while ago. Just need to pass the desired json object with _id. Closing.