Author Topic: LUA code not working anymore  (Read 291 times)

Offline P-a

  • Sr. Newbie
  • *
  • Posts: 37
  • Karma: +2/-0
LUA code not working anymore
« on: March 14, 2017, 06:53:55 am »
Hi guys and girls,

Is it just me or does anyone else experience issues adding LUA to new Scenes in VERA UI7?

Just simple things does not work? My new scenes keep firing regardless of LUA code like the one below?

local function Trix()
     local dID = 238       
     local allow = true       
     local status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",dID)
     return ((status == "1") == allow)
end

return Trix()


Input to offer?

Much appreciated!

Offline ember1205

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +5/-21
Re: LUA code not working anymore
« Reply #1 on: March 14, 2017, 08:53:44 am »
Here's an example of a LUA snippet I use to cause a scene to run during "Day" time:

Code: [Select]
local DayNight_Status = luup.variable_get("urn:rts-services-com:serviceId:DayTime","Status",DayNight_ID)
return (DayNight_Status == "1")

As you can see, it's a bit simpler than yours in that all it does is get the status and then executes a return of the actual status compared to a value of "1" (which represents "Day"). I never had much luck with the double equality things like you're trying to use and this has been solid for me. Also, I don't execute any sort of "return" inside my functions like this without a very specific reason to do so.

As an aside, I have global variables defined at startup to identify a few key devices in my system like the Day/Night Plugin and that's why this code is as short as it is.