NX V6 PTZ API
CompletedI am having an issue changing a cameras PTZ preset using the V6 API. Here is an example code snippet:
def set_ptz_preset(self, presets, name):
deviceId = "00874e2f-bc62-364d-f4ad-a3385150229e"
speed = {
"speed": 1.0
}
for preset in presets:
if preset['name'] == name:
preset_id = preset['id'].strip("{}")
url = f"/rest/v3/devices/{deviceId}/ptz/presets/{preset_id}/activate"
ptz_presets = self.api_call(url, 'POST', json=speed)
return ptz_set
When I send the request I get the following:
{"error":"3","errorId":"cantProcessRequest","errorString":"Failed to activate PTZ preset for Device '{00874e2f-bc62-364d-f4ad-a3385150229e}'."}
I also noticed when I GET the PTZ presets for a device, it returns the presets, but the device uuid in the response is all zeros like so:
[{'deviceId': '{00000000-0000-0000-0000-000000000000}', 'id': '{782ccdf2-a5bf-4c53-88d4-9c90333787c1}', 'name': 'closet'}, {'deviceId': '{00000000-0000-0000-0000-000000000000}', 'id': '{b439470b-ca61-4df6-838b-da09fc699487}', 'name': 'Door'}, {'deviceId': '{00000000-0000-0000-0000-000000000000}', 'id': '{e515dc17-b2a7-4e62-95ff-cba61795b712}', 'name': 'Home'}]
I am wondering if the deviceId not returning correctly is the issue, as the API does not know what device this preset is referencing?
-
Hi Jackson,
Thanks for your question, I have created an internal ticket on behalf of you.
Please check your mail inbox and we will coordinate with you via the ticket.Thanks.
-
We have confirmed that it is a bug that the Nx Server replies to the
Get PTZ presets
API/rest/v3/devices/{deviceId}/ptz/presets
with the zerodeviceId
.
This issue will be fixed in the next release. (i.e. Nx 6.0.2 and onward.)
Regarding theActivate PTZ Preset
API, thepresetId
is a string in the API structure, therefore, it should be circled by the curly brackets. Therefore, the API request should be like:POST /rest/v3/devices/<deviceId>/ptz/presets/{<presetId>}/activate
Body:
{
"speed": <speed>
}
Thank you.
Please sign in to leave a comment.
Comments
2 comments