Author Topic: Help Please - Scene LUA causing... Error in lua for scenes and events  (Read 878 times)

Offline Aaron

  • Hero Member
  • *****
  • Posts: 1985
  • Karma: +61/-193
Hoping you guys can help me understand why the below LUA (2 separate LUA in separate scenes) are causing the startup error.

thx


<Scene1 LUA below>

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)
-- Do NOT Run when Vacation or Aaron_Travel virtual switch is on
if (vacation_mode=="1" or aaron_traveling=="1") then
   return false
end



<Scene2 LUA below>

function resetSensor (device)
    local SECURITY_SENSOR_SERVICE ="urn:micasaverde-com:serviceId:SecuritySensor1"
    luup.variable_set (SECURITY_SENSOR_SERVICE, "Tripped", 0, device)
end

resetSensor(271)  -- Main Room Motion Vista 20p
resetSensor(149)  -- Dining Room Motion
resetSensor(552)  -- Entry Motion multi
resetSensor(209)  -- Garage Motion 2
resetSensor(164)  -- Garage Motion
resetSensor(567)  -- Living Room multi
resetSensor(155)  -- Media Room Motion
resetSensor(579)  -- Motion multi 1
resetSensor(151)  -- Mudroom Motion
resetSensor(150)  -- Office Motion Sensor
resetSensor(210)  -- Patio Motion Sensor
resetSensor(163)  -- Playroom Motion Sensor
resetSensor(571)  -- Deck Motion multi

Offline rlmalisz

  • Sr. Member
  • ****
  • Posts: 391
  • Karma: +1/-0
Re: Help Please - Scene LUA causing... Error in lua for scenes and events
« Reply #1 on: January 14, 2017, 02:24:56 pm »
Just a stab, but shouldn't both have a "return true" at the end?

--Richard

Offline Aaron

  • Hero Member
  • *****
  • Posts: 1985
  • Karma: +61/-193
Re: Help Please - Scene LUA causing... Error in lua for scenes and events
« Reply #2 on: January 14, 2017, 02:55:54 pm »
Just a stab, but shouldn't both have a "return true" at the end? 

--Richard

Thx for the help. I'm not 100% clear when 'return true' is needed.
Just one at the very end of each code set - Like below?

<Scene1 LUA below>

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)
-- Do NOT Run when Vacation or Aaron_Travel virtual switch is on
if (vacation_mode=="1" or aaron_traveling=="1") then
   return false
end

return true


<Scene2 LUA below>

function resetSensor (device)
    local SECURITY_SENSOR_SERVICE ="urn:micasaverde-com:serviceId:SecuritySensor1"
    luup.variable_set (SECURITY_SENSOR_SERVICE, "Tripped", 0, device)
end

resetSensor(271)  -- Main Room Motion Vista 20p
resetSensor(149)  -- Dining Room Motion
resetSensor(552)  -- Entry Motion multi
resetSensor(209)  -- Garage Motion 2
resetSensor(164)  -- Garage Motion
resetSensor(567)  -- Living Room multi
resetSensor(155)  -- Media Room Motion
resetSensor(579)  -- Motion multi 1
resetSensor(151)  -- Mudroom Motion
resetSensor(150)  -- Office Motion Sensor
resetSensor(210)  -- Patio Motion Sensor
resetSensor(163)  -- Playroom Motion Sensor
resetSensor(571)  -- Deck Motion multi


return true

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 10091
  • Karma: +763/-142
Re: Help Please - Scene LUA causing... Error in lua for scenes and events
« Reply #3 on: January 14, 2017, 07:32:08 pm »
return true  or NO return (i.e. just running out of code to run) will allow the  scene/trigger to continue.

return false  with cause the scene/trigger to be canceled.