diff --git a/README_JSON_API.md b/README_JSON_API.md index 98409405..633f02eb 100644 --- a/README_JSON_API.md +++ b/README_JSON_API.md @@ -317,7 +317,7 @@ curl -X PUT "http://localhost:3689/api/player/seek?seek_ms=-30000" | GET | [/api/outputs](#get-a-list-of-available-outputs) | Get a list of available outputs | | PUT | [/api/outputs/set](#set-enabled-outputs) | Set enabled outputs | | GET | [/api/outputs/{id}](#get-an-output) | Get an output | -| PUT | [/api/outputs/{id}](#change-an-output) | Change an output (enable/disable or volume) | +| PUT | [/api/outputs/{id}](#change-an-output) | Change an output setting | | PUT | [/api/outputs/{id}/toggle](#toggle-an-output) | Enable or disable an output, depending on the current state | @@ -482,6 +482,7 @@ PUT /api/outputs/{id} | --------------- | --------- | -------------------- | | selected | boolean | *(Optional)* `true` to enable and `false` to disable the output | | volume | integer | *(Optional)* Volume in percent (0 - 100) | +| pin | string | *(Optional)* PIN for device verification | **Response** diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index 993aeda7..5e731e52 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -1530,6 +1530,7 @@ jsonapi_reply_outputs_put_byid(struct httpd_request *hreq) json_object* request; bool selected; int volume; + const char *pin; int ret; ret = safe_atou64(hreq->uri_parsed->path_parts[2], &output_id); @@ -1566,6 +1567,13 @@ jsonapi_reply_outputs_put_byid(struct httpd_request *hreq) ret = player_volume_setabs_speaker(output_id, volume); } + if (ret == 0 && jparse_contains_key(request, "pin", json_type_string)) + { + pin = jparse_str_from_obj(request, "pin"); + if (pin) + ret = player_speaker_authorize(output_id, pin); + } + jparse_free(request); if (ret < 0)