background preloader

Wulften

Facebook Twitter

Lua for Beginners. Luup Variables. The "Variables" for a device tell you it's current state, such as if it's on or off, what temperature it has, and so on. Variables are given a name and a service ID, which is defined by the UPnP forum. You can use this service ID/variable name pair to get the state of a device in the Luup engine by using the function luup.variable_get, as documented in Luup_Lua_extensions. You can also see the current value of a device's variables by going into Vera's setup page, click 'Devices', click + next to the device, then click 'Advanced'. The name of every variable for the device is shown along with the current value, and if you move your mouse over the variable name, you will the corresponding service ID in a popup window.

Device category Device Category 3, UPnP device id: urn:schemas-upnp-org:device:BinaryLight:1 Variables Examples Getting whether the Switch/Light is on or off Request that the Switch be turned on. Device category 2, UPnP device id: urn:schemas-upnp-org:device:DimmableLight:1. Luup Scenes Events. Adding Lua code to scenes and events You can add Lua script to scenes and events for simple tasks, like making a scene or event conditional. Conditional meaning "do something only if some condition is met", such as attaching a condition to your "Come Home" scene so it is only run if the temperature is over 70 degrees. Basic conditional expressions are easy, and, if that's all you're looking to do, skip to the walk-through below.

If you're more technically inclined you can also do very advanced things too. For an overview of all the advanced things you can do with Vera's Luup engine, and how scenes and events fit in, see the Luup Intro page. To add Lua code to a scene, create the Scenes and click 'Luup scene'. Fill in your Lua code in the input box. You can also add Lua code to an event by clicking 'Luup event'. When you edit the Lua code in a scene or event you must click 'Save' before the code is saved.

Urn:upnp-org:serviceId:TemperatureSensor1 CurrentTemperature Samples Scene Actions 1. Luup Lua extensions. In addition to the [Lua] commands described in the [Lua reference manual], you can also reference in your Lua code variables and functions from modules which the Luup engine provides as follows: Module: luup These are general purpose functions and variables. Call them by using the luup. module, such as: luup.log('Now running version: ' .. luup.version) variable: device The ID of this device instance, if it's running as part of a device variable: version, version_branch, version_major, version_minor version contains the version of the luup engine, such as "1.0.843", as a string.

If( version_branch ~= 1 or version_major ~= 0 or version_minor < 843 ) then luup.log("I need version 1.0.843 minimum to run") return falseend variable: longitude Contains the longitude as a number, as found on the location tab in the setup UI. variable: latitude Contains the latitude as a number, as found on the location tab in the setup UI. variable: timezone variable: city variable: devices The members are: variable: rooms. Lua Directory. This page is a top level directory of all Lua content at this wiki, grouped by topic. Introduction to Lua LearningLua - introduction to Lua (a guided directory) LuaTutorial - an informative tutorial written and reviewed by Lua users SampleCode - snippets of useful Lua code LuaComparison - how Lua compares with other languages. LuaFaq - unofficial, community-maintained frequently asked questions LuaLinks - a hand-edited list of useful Lua links LuaBooks - list of books on the subject of Lua Language Definition and Features LuaShortReference - concise summary of the Lua 5.1 syntax and core libraries LuaReferenceManualComments - user comments and annotations on the Lua Reference Manual.

LuaSymbols?