Dynamic URL in Settings Tab of Plugin

I’m developing a plugin for a device that includes its own http based administration system. I currently have a hyperlink set up in the .json UI file for the device that has the URL hardcoded. However, I’d like to make this URL dynamic. Simply, whatever the vera configured “ip” address is of the device is, I’d like it to be a url an http URL for that device.

Here’s a code snippet from my current plugin from the D_*.json file. Note this is currently rendering the hyperlink, but it is hardcoded:

				{
					"ControlGroup": "2",
					"ControlType": "label",
					"Label": {
						"lang_tag": "chrec",
						"text": "<a href='http://192.168.1.123/' target='_blank'>Configuration System</a>"
					},
					"top": "1",
					"Display": {
						"Top": 60,
						"Left": 10,
						"Width": 120,
						"Height": 20
					}
				}	

I’d like the plugin to somehow substitute the ip address for CONFIGURED IP ADDRESS at runtime Configuration System

Any thoughts on approaches would be appreciated.

Thanks!

Do the Settings tab in Java Script … and you can do what ever you want!

See the Day or Night Plugin for a simple example:
D_DayTime.json
J_DayTime-UI5.js
and
J_DayTime-UI6.js

Thanks for the quick reply. I downloaded the day or night plugin.

I got the items to render, but I’m having a couple of problems. I applogize in advance, my UI coding skills are pretty rusty and I’ve never done json in javascript. I referenced http://wiki.mios.com/index.php/JavaScript_API

Problem #1
I can’t seem to get the ip address of the device. Things rendered fine until I added the line that tries to make the URL dynamic. I’m guessing this is my use of “var systemIp = jsonp.ud.devices[deviceID].ip;” that is causing the problem.

[code]var hid_Svs = ‘urn:hidglobal-com:serviceId:EdgePlusSolo1’;

function hidEdgeSoloPlus_Settings(deviceID) {
var lastUser = get_device_state(deviceID, hid_Svs, ‘TimeStatusMessage’);
var lastEntryTime = get_device_state(deviceID, hid_Svs, ‘LastEventDate’);

var systemIp = jsonp.ud.devices[deviceID].ip;
var dynamicLink = 'http://' + systemIp + '/';

var html =  '<table width="100%">' +
    ' <tr><td> HA Last User : ' +  lastUser + '</td></tr>' +
    ' <tr><td>Last Entry : ' +  lastEntryTime + '</td></tr>' +
    ' <tr><td><a href="' + dynamicLink + '" target="_blank">HID Edge Solo Configuration</a><tr><td>' +
	'</table>';
set_panel_html(html);

}[/code]

Problem #2
Even before I tried to make the URL Dynamic, which I clicked on the “Control” tab (which is where I put this javascript page), it would display “Opening hidEdgeSoloPlus_Settings…” for a long time. It wasn’t until I changed focus to a different tab and came pack that it at least displayed. Is there a problem using the javascript page as the “Control” tab? Any thoughts?

P1: You can get the host name from:
document.location.hostname;

Look in init.js and cpanel_data.js
Lot of useful examples of code snippets.

P2:
Sounds like your javascript is not get loaded … I recommend using a JavaScript developement environment (Chrome and Firefox development tools work well with Vera).
You can monitor the console to see errors from the JavaScript tools.