Code for Port Specification that is Persistent


Using an Amcrest camera with an implementation file on this forum, it appears after luup restarts that the port does not retain. IP address is fine.

In this thread @guessed has a reference to specifying the port. I cannot seem to lock down internet searches to do this.

The camera will not connect because the port is lost, this does not happen with regular Vera cams such as Vista cam. What can I add to the implementation file to have the port setting retain?

-- Get username, password and IP lug_username = luup.devices[lul_device].user or luup.variable_get(CAM_SID, "Username", lul_device) or "" lug_password = luup.devices[lul_device].pass or luup.variable_get(CAM_SID, "Password", lul_device) or "" lug_ip = luup.devices[lul_device].ip or ""


I have not used a nonstandard port (other than default 80) with Amcrest cameras but with some Foscam cameras that is needed as those listen to port 88, instead of 80.

In that case port is simply added to the camera IP address using a colon as separator.


This should also work with the current implementation file as the port becomes part of the ip-variable.

Thanks and I believe I used your instructions.

I’m well versed in the port and ip. I don’t know why sometimes the port magically dissapears after a LuupRestart other times it does not.

When using the url in your pdf I add the port at the time of creation. It works for a while then the port just removed itself and I manually add it back in from the extra parameters page or even the variable tab.

I really don’t know how else to explain the behavior.

When the port is there it works fine and even snapshots are saved to Vera’s servers.

Sent from my VS995 using Tapatalk

Strange things can happen, so I don’t question that your issue is real.

This untested additional line of code should add the port to the IP every time the Luup reloads the plugin-code.
The Luup extension reference for the the attr_set function can be found from here : [url=][/url]

function lug_startup(lul_device)

lug_ip = luup.devices[lul_device].ip or “”

– Add port defined by string PORT to the camera IP address to make it persistent
luup.attr_set(“ip”, lug_ip … “:PORT”, lul_device)

If you want to make the port configurable in the device variables, instead of hard coding it in the implementation file, then add a variable with default value with luup.variable_set and get the value with luup.variable_get before using the value in the attr_set.

Thank you! I’ll definitely work on this. As luup engine has calmed down recently the port has remained without issue. But this isn’t the first time it has happened. It occurred on Vera’s own camera a while back. No fix but to constantly add it back till the system calmed down. But thanks, appreciate the time and code snips.

Sent from my VS995 using Tapatalk

In the course of my own plugin work I’ve discovered that Luup does mysterious things in the background when the ip and mac attributes are set. My guess is that it goes to considerable effort to maintain connections to the device (reopen faulted or closed connections transparently, etc.), and may even use the MAC address to try to find a device at a new IP address if the device moves (DHCP dynamic assignment). It is conceivable to me that this process may have a bug in which the port is accidentally dropped when the IP address is rewritten.

Good point and I got it now on static IP. When Comcast updates the routers it’s almost as bad as Vera firmware. So some ip’s will retain and some bounce around.

I went back and reserved everything I could and set static where possible too.

On a side note the latest firmware removed their text file network backup for Comcast so that pissed me off. Never change from their default because if you have to reset it’s like reincluding all your zwave devices again.

Sent from my VS995 using Tapatalk