I am writing a SmartApp to expose the camera in my Swann NVR. It supports 5 cameras and you can take snapshots with an HTTP request which returns an image as a response. I implemented a SmartApp which will create a device for each camera.
Each camera has a take() action which will make the HTTP request to get the snapshot from the camera. My understanding (and proven by experiments) is I can’t get a response from a LAN action (to request the snapshot) unless I set the deviceNetworkId for the device to the address and port (in hex of course) of the remote device. The problem arises in that I want to have separate devices, one for each camera, so snapshots can be separated. This means I need to create 5 different devices, all with the same address – which of course doesn’t work.
I thought I could just implement the snapshot functionality in the SmartApp and have the devices call the SmartApp to make the call and get the response in the location handler. The problem is I don’t know which device a snapshot is for from the incoming request. The response doesn’t appear to have the request path that was made and the request Id that is present is opaque.
So three questions:
When you get an incoming message in your locationHandler is there any way to determine the path or other data about the request that was made in order to get this response?
Is there any way to allow multiple device instances to share the same network Id?
Any other suggestions on approach? All the examples I have found have cameras which each have their own IP Address.
I do not want to track a state value for which camera is currently taking a picture if I can help it – which is the only way I can think of working around this problem.