Camera plugin

MCV, is D_DigitalSecurityCamera1.xml a working device?

I tried to create a basic camera device out of it, but it doesn’t show any controls or fields to enter the config data (even though the configuration service seems to be there).

If it’s more of a template then a working device, how can we know what’s missing to make it work, at least with the very basic functionality (enter URL - display image)?

It’s a working device. It’s created automatically when it detects a Panasonic camera. See /usr/bin/cmh_PnP:

curl -o /tmp/$IP.temp “http://127.0.0.1:49451/data_request?id=lu_action&$SERVACT&deviceType=urn:schemas-upnp-org:device:DigitalSecurityCamera:1&UpnpDevFilename=D_DigitalSecurityCamera1.xml&UpnpImplFilename=I_PanasonicPTZ.xml&IpAddress=$IP&MacAddress=$MAC&StateVariables=urn:micasaverde-com:serviceId:Camera1,Username=dceadmin urn:micasaverde-com:serviceId:Camera1,Password=dcepass&output_format=xml

I’d suggest creating the device first with the same options as the panasonic, which we know works, and then modify the username/password/ip/etc., and update the Path to whatever path your camera users. Note you can also look at: I_PanasonicPTZ.xml which has the pan/tilt/zoom commands for the panasonic. It’s trivial to change them to whatever your camera supports.

It’s good to have you back :slight_smile:
I want to create something, no matter what - that works, and modify it step by step to suit my camera’s specification.
When I created a device using D_DigitalSecurityCamera1.xml (I don’t have Panasonic cam on my LAN) I expected to see some settings or controls, but all I saw was “empty” device.
What went wrong?

Upgraded to FW .765

I went to Devices, pasted D_DigitalSecurityCamera1.xml into Add Device, saved.

No sights of Camera controls - just an empty device. Any idea?

Would you mind submitting a trouble ticket? Advanced, tech support, submit. Post the ticket ID here, and I can retrieve it from our server. It will have a copy of your user_data.json, which I can run on my local system to see why you don’t have the camera.

Submited ticket: 828

I found the problem and fixed it in this firmware: http://download.controlmyhouse.net/betafirmware/ftp/wl500gP-1.0.766.trx

That also has the new debug info you asked for on the other thread. With 766, I installed your user_data (which will stay in tact if you upgrade with preserve settings), I clicked ‘+’ next to the camera, chose advanced, filled in the IP address, and at the bottom in the new service/variable/value, I added teh following variables (click add after each one):

service: urn:micasaverde-com:serviceId:Camera1 variable:Username value: dceadmin
service: urn:micasaverde-com:serviceId:Camera1 variable:Password value: dcepass
service: urn:micasaverde-com:serviceId:Camera1 variable:URL value: /SnapshotJPEG?Resolution=320x240&Quality=Standard

You can leave teh username/password off if you don’t have http authentication. After saving, I see a javascript error, and you get a series of … … … after it saves. Just reload the page. Then you can view the camera, but not move it. Go back to that page and put: I_PanasonicPTZ.xml in the UPnPImplFile field, again save, now pan/tilt/zoom works. Again a java script error and an ‘undefined’ javascript popup. I’ll ask our javascript programmer to fix them today.

Looks much better now - thanks!

Is it possible to define static fields, so user instead of populating service, variable and value would see username, pwd, and URL?

Yes, it’ll be in there in a couple days. I saw this was a pain too. It’s not an issue with the plug-n-play stuff because that fills it in for the user.

Good.

Then the question is what’s required to make a new device plug-n-play in Luup?

Assuming the device in question is not UPnP, like the IP cameras we’re using, there’s no ‘official’ way to find them on the network. So, what we’ve done with Vera is add a low-level LAN monitor that listens for all IP requests (ie DHCP) whether or not Vera is the DHCP server. When this monitor determines a new IP device is on the network, it calls /usr/bin/cmh_PnP. This is a simple ‘brute force’ script that does wget’s on the IP address to match against known patters for devices. You’ll see right now we have pattern matching for the Panasonic cameras, the GC100, and the D-Link. If you want to add a device and make it plug and play, send us the ‘if’ statement we should add to the check portion, like this:

        if curl -o /tmp/$IP.temp.gc100 -k -s -S --fail --connect-timeout 1 --max-time 1 "http://$IP/index.html" --stderr $err_file && grep GC-100 /tmp/$IP.temp.gc100 ;then
			log "It's a gc-100"
			IsGC100=1
			break;
		else
			log "It isnt a gc100"
        fi

and the device creation line, like this:

curl -o /tmp/$IP.temp "http://127.0.0.1:49451/data_request?id=lu_action&$SERVACT&deviceType=urn:schemas-upnp-org:device:DigitalSecurityCamera:1&UpnpDevFilename=D_DigitalSecurityCamera1.xml&UpnpImplFilename=I_PanasonicPTZ.xml&IpAddress=$IP&MacAddress=$MAC&StateVariables=urn:micasaverde-com:serviceId:Camera1,Username=dceadmin%0Aurn:micasaverde-com:serviceId:Camera1,Password=dcepass&output_format=xml"

We’ll add this to the cmh_Pnp script for the next release.

The camera server I’m working with can handle two cameras at once, on the same IP.
So I expanded my plugin to create two child devices. I don’t exactly understand based on what Vera decides when to display camera-specific
controls, but in my case it keeps displaying everything on parent device, and just View/Hide button on child devices. If I click that button on child device
it doesn’t display an empty image as it does on the parent. Why?

Another question is: I need a startup function to create the child devices, so I created implementation file. In Somfy example you suggested to remove
Services from device xml file when add implementation file, so did I by removing all 3 camera related services from my D_* file. Is it right? How can I ensure
all relevant settings and PTZ functionality will be there without their service definitions?

Actually what I’d recommend is create a new D_ file for “Camera Controller”, which has it’s own DeviceType, which has a model-specific name (ie “Acme DVR Controller” or something). This top-level device will probably have no services. It will have an implementation file. And the implementation file’s startup function will use the “Child_Device” functions to create a standard D_DigitalSecurityCamera1.xml (deviceType: urn:schemas-upnp-org:device:DigitalSecurityCamera:1) device for each of the cameras it can control, and when you call AddChild, include the ‘Embedded’=1 flag if you want the parent and all the child to be grouped together into 1 single block in the UI. This would work for DVR systems as well, where it’s really one composite device. The UI will show the ‘view camera’ control for all the child devices with device type: urn:schemas-upnp-org:device:DigitalSecurityCamera:1. There will be no controls for the parent device since it’s an unknown device type to the web UI.

Note that the implementation file for the Panasonic pan/tilt/zoom is not put in an ‘implementationFile’ tag in the D_DigitalSecurityCamera1.xml. We could have created a D_PanasonicCmaera.xml device file just for the Panasonic, which had the same device type, so the UI shows camera controls, and which has an ‘implementationfile’ tag for the I_PanasonicPTZ. But, since there are so many IP cameras, I just created a standard D_DigitalSecurityCamera1.xml which could be used for all of them, and put the implementation file in the user-specific database. This is shown when you click the ‘advanced’ button for the device in the UPnPImplFile field. So, when attaching an Impl file to a device you can either: a) hardcode it in the device file, b) manually put it in the user database in the UPnPImplFile field, or c) If creating the device using the Child_Devices Luup functions (like you’ll do), specify it in the AddChild function (which just puts it in the UPnPImplFile field for you).

In your case, you’ll have 2 ways to put any implementation for pan/tilt/zoom. a) if all the cameras on the DVR use the same commands, and you want to handle the PTZ functions in the same file as your startup code, just add the handlechildren flag like I did in the Somfy example, and all the PTZ commands destined to a child device (camera) will get processed in the parent’s implementation file. or b) you can create one or more implementation files for the camera which handle the PTZ actions.

Thanks! Besides the fact I spend two hours trying to figure out why my D_ changes are ignored (had to create a new clean
device from the same XML to see them), it behaves as expected now.

Now the questions:

If I add implementation file into D_ and another implementation file to UPnPImplFile field - will they both get processed (lug_startup etc)?

  1. [quote=“micasaverde, post:7, topic:164599”]service: urn:micasaverde-com:serviceId:Camera1 variable:Username value: dceadmin
    service: urn:micasaverde-com:serviceId:Camera1 variable:Password value: dcepass
    service: urn:micasaverde-com:serviceId:Camera1 variable:URL value: /SnapshotJPEG?Resolution=320x240&Quality=Standard[/quote]

URL value as defined above is supposedly shared between the child devices, even though so far I can’t make child devices
to see parent’s variables.
But in my case each camera requires customized URL: it addressed by parameter ?cam=1 or =2.

What should I do to allow each child device to have its own URL?

You mean lu_chdev_append, right? Could you post the function’s signature with description - I have no idea how to send implementation file name as an argument…

  1. Yes, both get processed.

  2. You have 2 ways to give them their own URL’s. Either, a) in the startup code register different requests, like: lr_cam1, lr_cam2, etc., or b) (probably better) is register one request (lr_cam), but pass the camera id on the URL, like: data_request?id=lr_cam&camera=2. Is that clear? If not, we can do a Skype or phone call to be sure the concept is ok.

  3. I documented it here: http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#Reporting_child_devices

Well, requests handling is very interesting subject that deserves a nice chapter in wiki. - once understood it can open another degree of flexibility.
I went through L_WapUI.lua in attempt to understand how it works, but sadly, lr_* variables are just used there - it’s not clear where they come from, and how they get initialized.
It would be nice to have detailed description of lu_RegisterHandler function too.

Anyways, I passed URL to the child devices as parameter of lu_chdev_append, it’s all good now.

I also wrote PTZ control file, but I can’t test it due to “Delivery failed” problem.

I added some documentation for it here: http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#General_purpose

I read it… I only can say “Wow”… It’s essentially LUA servlets!

To say just “it’s incredibly cool” would be serious understatement

Ok, iCamView plugin works, everything is nice… on the Devices page.

But…

  • on the full size view image is shown but controls don’t seem to trigger actions

  • on Dashboard clicking on View Camera does nothing, not even the image

that will be a javascript error. If you want to talk directly to our javascript programmer, his email is vali@ and he can fix it. He’s on vacation until August 3, though. Unfortunately the rest of us don’t know javascript at all, so it’s unlikely we’ll be able to fix until he’s back. Sorry.