MarkGodwin / tplink-omada-api

MIT License
12 stars 9 forks source link

Ability to set client name #24

Closed lyricnz closed 6 months ago

lyricnz commented 1 year ago

It would be useful if there was a method to set the name/username for a device. Then we can use either a static list, or arp (!), to push human-readable names into the controller.

lyricnz commented 1 year ago

Looks like a PATCH to the client URL

{"name":"smartplug6","rateLimit":{"enable":false},"clientLockToApSetting":{"enable":false},"ipSetting":{"useFixedAddr":false}}
lyricnz commented 1 year ago

OK, found the API docs from https://community.tp-link.com/en/business/forum/topic/590430

And submitted the patch. Worked fine.

                payload = {
                    "name": f'WAS {x.name}',
                    # "rateLimit": {
                    #     "enable": False
                    # },
                    "clientLockToApSetting": {
                        "enable": False,
                    },
                    "ipSetting": {
                        "useFixedAddr": False
                    }
                }
                result = await site_client._api.request(
                    "patch",
                    site_client._api.format_url(f"clients/{x.mac}", site_client._site_id),
                    payload=payload,
                )
lyricnz commented 1 year ago

FWIW the reason I ask is that the default "name" field appears to be mostly useless, and that's what's used on the map. I'd like to set each device to the name from the reverse-dns for the IP. The controller already has most of the hostnames in a different column...

MarkGodwin commented 12 months ago

Yeah, I haven't added any parts of the clients api yet. When I do this, I will be sure to include this feature. Or, if you want to submit a PR... :)