Author Topic: Help fixing LUA startup errors in UI7, did not happen UI5 <Log attached>  (Read 960 times)

Offline Aaron

  • Hero Member
  • *****
  • Posts: 1985
  • Karma: +61/-193
I have this same error no matter what. It seems to read all the scenes, in order. So, before, it threw the error on Scene #7. I deleted out all LUA code on Scene 7 - which was simply one line... os.execute( 'reboot' )

I then restarted Vera and it now errors on Scene 24 (as shown below). I suspect it will error on ALL scenes that have any LUA code?

These were working perfectly in UI5. What do I need to do diff now?

Quote
01   01/03/17 23:21:11.566   LuaInterface::LoadCode: [string "function scene_24()..."]:206: 'end' expected (to close 'function' at line 202) near 'luup' <0x77933320>
01   01/03/17 23:21:11.595   JobHandler_LuaUPnP::Run cannot start lua with code:
function scene_24()
local vacation_mode = luup.variable_get("urn:dcineco-com:serviceId:MSwitch1","Status7",224)
local aaron_traveling = luup.variable_get("urn:dcineco-com:serviceId:MSwitch1","Status7",223)
--disable when Vacation or Aaron_Travel virtual switch is on
if (vacation_mode=="1" or aaron_traveling=="1") then
   return false
end


thanks for the help!

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 857
  • Karma: +63/-8
Re: Help fixing LUA startup errors in UI7, did not happen UI5 <Log attached>
« Reply #1 on: January 04, 2017, 02:57:01 am »
Couple of problems: you never return a true condition and when you don't return a false, you have no end for the function; only the end for the if statement. This may work OK?

Code: [Select]
function scene_24()
    local vacation_mode = luup.variable_get("urn:dcineco-com:serviceId:MSwitch1","Status7",224)
    local aaron_traveling = luup.variable_get("urn:dcineco-com:serviceId:MSwitch1","Status7",223)

    --disable when Vacation or Aaron_Travel virtual switch is on
    return  vacation_mode=="0" and aaron_traveling=="0"

end

Offline Aaron

  • Hero Member
  • *****
  • Posts: 1985
  • Karma: +61/-193
Re: Help fixing LUA startup errors in UI7, did not happen UI5 <Log attached>
« Reply #2 on: January 04, 2017, 04:35:29 pm »
I think I figured it out... crazy!

On one scene I had...

Code: [Select]
luup.set_failure(false,287)
return true

luup.set_failure(false,190)
return true

Vera didn't like this even though it works fine in the LUA Tester from Vera and the one Rex B posted.

Should there only be 1 'return true' at the end?


« Last Edit: January 04, 2017, 04:55:34 pm by Aaron »

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 857
  • Karma: +63/-8
Re: Help fixing LUA startup errors in UI7, did not happen UI5 <Log attached>
« Reply #3 on: January 05, 2017, 01:38:09 am »
The line second line will always return - it returns true

The two lines after that are therefore unreachable and produce an error. If you comment them out it, will work OK for the first two lines.

Code: [Select]
luup.set_failure(false,287)
return true

luup.set_failure(false,190)
return true