javascript api

I am confused about the way the following api’s work , any one give me some clarity? I also can’t get setDeviceState to work at all is this a bug, I did look at bug tracker but couldn’t find anything. why are they implemented differently?

setDeviceState(deviceId, service, variable, value, options)

setDeviceStatePersistent(deviceId, service, variable, value, options)

setDeviceStateVariable(deviceId, service, variable, value, onSuccess, onFailure, context)

setDeviceStateVariablePersistent(deviceId, service, variable, value, onSuccess, onFailure, context)

So many questions and no answers.

The following does however work: -

	function setDeviceStateVariable(DEVICE, SID, VARIABLE, VALUE)
	{
		api.setDeviceStatePersistent(DEVICE, SID, VARIABLE, VALUE,
		{
			'onSuccess': function()
			{
				ShowStatus('Data updated', false);
			},
			'onFailure': function()
			{
				ShowStatus("Failed to update data. Reload LuuP and try again", true);
			}
		});
	}

Thanks

  1. api.setDeviceState() and api.setDeviceStateVariable() are the same - they set a value for a given device id, service and variable

Ex. (from browser JavaScript console):

api.setDeviceState(154, ‘urn:upnp-org:serviceId:AllControls1’, ‘MyTestVariable’, ‘JustAValue’);
undefined
api.getDeviceState(154, ‘urn:upnp-org:serviceId:AllControls1’, ‘MyTestVariable’);
“JustAValue”

The value set in this manner will be lost if you refresh the browser.

  1. api.setDeviceStatePersistent() and api.setDeviceStateVariablePersistent() are the same - they set a value for a given device id, service and variable; the value will be kept after ‘reload’

Ex.:

api.setDeviceStatePersistent(154, ‘urn:upnp-org:serviceId:AllControls1’, ‘MyBigVariable’, ‘A persistent one’);
undefined
(refresh the browser)
api.getDeviceState(154, ‘urn:upnp-org:serviceId:AllControls1’, ‘MyBigVariable’);
“A persistent one”

The value set in this manner will be written to the user_data.