Diff?rent behaviour between pleg and Dev app text box.

Is There ? reason why the LUA code act differently between the Dev app text box vs pleg plug in ?

Especially for value of the method string.format ???

Are they supposed the react the same way ??

The behavior should be the same.

But, PLEG does not have access to any variables from your Startup LUA and conversely Startup LUA can not access any variables in a PLEG device.

I dont mean i’m trying to get variables from the startup or anyother environment of the VERA router. I just mean there is a different behaviour with the LUA code such as ;

local THERMOSTAT = 220
local WORKINGTARGET = 0.00
–swing std est a 0.5 en celcius, possiblement a 1 en farenheith.
local SWINGSTD = 1.00
– swing adjusted doit etre a 0.1 quand celcius
local SWINGADJUST = 0.50
local TRUETARGET = 0.00
local USERTARGET = 0.00
local CURTEMP = 0.00
local CURTIME = os.date(‘%I:%M’)
local RIEN = “RIEN”
local LASTDECISION = RIEN
local HEATON = “HEATON”
local HEATOFF = “HEATOFF”
local MSGHEATSTART = “Chauffage demarre”
local MSGHEATSTOP = “Chauffage arrete”
local CLASSTHERM = “urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”
local CLASSTEMPSENSOR = “urn:upnp-org:serviceId:TemperatureSensor1”
local CLASSMULTISTRING = “urn:upnp-org:serviceId:VContainer1”

–lecture du thermostat temp desiree
USERTARGET = luup.variable_get(CLASSTHERM, “CurrentSetpoint”, THERMOSTAT)
luup.variable_set(CLASSMULTISTRING, “Variable3”, USERTARGET, 48)

–lecture du thermostat temps reelle
CURTEMP = luup.variable_get(CLASSTEMPSENSOR,‘CurrentTemperature’, 220)
luup.variable_set(CLASSMULTISTRING, “Variable2”, CURTEMP, 48)

–lecture du target working
WORKINGTARGET = luup.variable_get(CLASSMULTISTRING,‘Variable5’, 48)

CURTEMP = tonumber(string.format(“%.02f”, CURTEMP))
USERTARGET = tonumber(string.format(“%.02f”,USERTARGET))
WORKINGTARGET = tonumber(string.format(“%.02f”,WORKINGTARGET))

– si target courant est <> du working target cest quil a ete change manuellement via
– le thermostat, le mode home, away, etc…, ou directement dans l’application
if not (USERTARGET == WORKINGTARGET) then
– prendre le user target du thermostat et prendre comme nouveau true target
TRUETARGET = USERTARGET
luup.variable_set(CLASSMULTISTRING, “Variable1”, string.format(“%.02f”, TRUETARGET), 48)
luup.variable_set(CLASSMULTISTRING, “Variable2”, “User et work diff applique new target”, 50)
luup.variable_set(CLASSMULTISTRING, “Variable4”, string.format(“%.02f”,TRUETARGET), 50)

– permettre le changement le working target si change manuellement
luup.variable_set(CLASSMULTISTRING, “Variable1”, RIEN, 50)
else
– si le target du thermostat est toujours sync avec le working target alors tout simplement importer true_target
– afin de pouvoir evaluer plus tard si on doit reajuster en fonction de la temp courant
luup.variable_set(CLASSMULTISTRING, “Variable2”, “User et work pareil donc eval only cur temp vs true target”, 50)
TRUETARGET = luup.variable_get(CLASSMULTISTRING,‘Variable1’, 48)
end

TRUETARGET = tonumber(string.format(“%.02f”, TRUETARGET))
LASTDECISION = luup.variable_get(CLASSMULTISTRING,‘Variable1’, 50)

–2 condition afin devaluer si on doit ouvrir ou couper le chauffage
if (CURTEMP <= (TRUETARGET - SWINGADJUST)) then
if ((LASTDECISION == HEATOFF) or (LASTDECISION == RIEN)) then
WORKINGTARGET = TRUETARGET+SWINGSTD
luup.call_action(CLASSTHERM, “SetCurrentSetpoint”, {NewCurrentSetpoint = WORKINGTARGET},220)
luup.variable_set(CLASSMULTISTRING, “Variable3”, string.format(“%.02f”, WORKINGTARGET), 48)
luup.variable_set(CLASSMULTISTRING, “Variable4”, (MSGHEATSTART … " : " … CURTIME), 48)
LASTDECISION = HEATON
luup.variable_set(CLASSMULTISTRING, “Variable1”, LASTDECISION, 50)
else
luup.variable_set(CLASSMULTISTRING, “Variable3”, “Chg deja applique heat on”, 50)
end
end
if (CURTEMP >= (TRUETARGET + SWINGADJUST)) then
if ((LASTDECISION == HEATON) or (LASTDECISION == RIEN)) then
WORKINGTARGET = TRUETARGET-SWINGSTD
luup.call_action(CLASSTHERM, “SetCurrentSetpoint”, {NewCurrentSetpoint = WORKINGTARGET},220)
luup.variable_set(CLASSMULTISTRING, “Variable3”, string.format(“%.02f”, WORKINGTARGET), 48)
luup.variable_set(CLASSMULTISTRING, “Variable4”, (MSGHEATSTOP … " : " … CURTIME), 48)
LASTDECISION = HEATOFF
luup.variable_set(CLASSMULTISTRING, “Variable1”, LASTDECISION, 50)
else
luup.variable_set(CLASSMULTISTRING, “Variable3”, “Chg deja applique heat off”, 50)
end
end
luup.variable_set(CLASSMULTISTRING, “Variable5”, string.format(“%.02f”, WORKINGTARGET), 48)