Scene code changed after editting

Hi I have some lua code in a scene which runs fine

[code]local http=require’socket.http’
local OW_urltemplate = “http://192.168.2.252:3000/%s/temperature12
local sensenames = {“Tank Top”, “Tank Middle”, “Tank Bottom”, “Cold Tank”, “Airing Cupboard” }
local senseids = {“28.CD54A3040000”, “28.EA5CA3040000”, “28.FE55A3040000”, “28.742AC3040000”,“28.B172A3040000” }
local devid = {33,34,35,36,37}
function round2(num, idp)
return tonumber(string.format(“%.” … (idp or 0) … “f”, num))
end
function getnextract_temp(owid)
local url = string.format(OW_urltemplate, owid)
local tdata, retcode = http.request(url)
startpos=string.find(tdata,“temperature12”)+26
return tonumber(string.sub(tdata,startpos,startpos+11))
end

for x=1,5 do
mytemp = round2(getnextract_temp(senseids[x]),2)
luup.variable_set(“urn:upnp-org:serviceId:TemperatureSensor1”, “CurrentTemperature”, mytemp , devid[x])
end[/code]

If I go in and edit the scene and look at the code this line
startpos=string.find(tdata,"temperature12</B></TD><TD>")+26
is always changed to
startpos=string.find(tdata,"temperature12")+26

so If I edit the scene I always have to correct the line and submit - scene runs fine then (until the next time I edit it)

its not a major problem - I just have to remember to do it

This is running on a RPI openLuup vs v16.10.23 Altui vs v1.73.1947

regards

Nik

Yes, I can duplicate this. using:

"temperature12</B></TD><TD>"

which gets translated to:

x = "temperature12"

The HTML request to create the scene is:

/data_request?id=scene&action=create&json=%7B%22timers%22%3A%5B%5D%2C%22triggers%22%3A%5B%5D%2C%22groups%22%3A%5B%7B%22delay%22%3A0%2C%22actions%22%3A%5B%5D%7D%5D%2C%22name%22%3A%22HTML%20test%22%2C%22lua%22%3A%22x%20%3D%20%5C%22temperature12%3C%2FB%3E%3C%2FTD%3E%3CTD%3E%5C%22%5Cn%22%2C%22room%22%3A0%2C%22modeStatus%22%3A%220%22%2C%22paused%22%3A0%7D 

which, when url-decoded reads:

{"timers":[],"triggers":[],"groups":[{"delay":0,"actions":[]}],"name":"HTML test","lua":"x = \"temperature12</B></TD><TD>\"\n","room":0,"modeStatus":"0","paused":0}

This is correct, so the error seems to be in openLuup.

Well it definitely saves it ok because the scene runs fine and populates the devices with the correct temperatures it only becomes a problem when you re-edit the scene and it doesnt matter if you open the LUA tab or not.

regards

Nik

Ah, interesting! I hadn’t appreciated that subtlety. I will have to did deeper. Would be good to try this on a Vera.

Yes I just tried it on the Vera and the same thing happens it loses the

</B></TD><TD>

when you go in and re-edit it (didnt run the scene though)

Edit: btw using the vera scene editor doesnt lose the code between edit

Ah well, that IS an AltUI issue, then.

Must be a scene read error in the code somewhere (probably a string matching problem.) Help @amg0!

I think I know what it is, it is saved properly and it is at the time of display when you enter the editor that the html characters are removed. I ll have a fix in next release

EDIT : you can try the beta in GitHub - amg0/ALTUI: Enhancement Interface for VERA home automation system

Yes, works great. Thanks!