Doubt regarding events and Lua

Hello everybody,

I’ve written a plugin in Luup and the device works correctly. But now I need a new feature, that I think theoretically it should be simple. I’m a little bit confused and digging forum didn’t clarify

I need to trigger something (like sending an email) when a variable of my plugin (for example a binary flag) is set to another value (for example by external invocation from an UPnP device or by http request). My doubt is in fact two doubts:

  • I dont know how to make my custom plugin variables trigger events in Vera. In the UI5 I see in the menu advanced that I can use my device actions in scenes, but I cannot use my variables as triggers of other scenes (like it does a zwave motion sensor that is tripped). I would like to know how to create, if its possible, new triggers usable from UI5 (actually I don’t know if this is possible), based on the variables of my device, or at least being able to handle events with Luup whenever my state variables change value. I don’t know how to transform my variables into event generators with Lua. I don’t know if it’s due to lack of UPnP knowledge.

  • The second doubt is regarding sending the mail by a trigger. Supposing that first issue is solved, now I would need to send an email as a reaction. I’ve seen that there are some plugins regarding this subject but I would like to know what is the best or more popular solution to send a simple email when an event occurs.

Thanks a lot in advance
and best regards.

You define the events in your json file under the eventList2 tag. See below for a simple example that allows a scene to be triggered when the state variable RxCode is equal to some text value. The event will be shown in scene Trigger tab, Add Trigger as IR code receved and the test value will be entered in the field Code:.

"eventList2": [ { "id": 1, "label": { "lang_tag": "ir-code-received", "text": "IR code received" }, "serviceId": "urn:dcineco-com:serviceId:KiraRx1", "argumentList": [ { "id": 1, "prefix": { "lang_tag":"code", "text":"Code:" }, "dataType": "string", "name": "RxCode", "comparisson": "=", "suffix": { "lang_tag":"", "text":"" }, "HumanFriendlyText": { "lang_tag": "ir-code-received", "text": "IR code received" } } ] } ],

For a more comprehensive example, take a look at the end of the json for chixxi’s VariableContainer plugin.

I believe it is also necessary to specify your state variable as causing events. You do this in S_xxxxx.xml. For example:

<stateVariable sendEvents="yes"> <name>RxCode</name> <dataType>string</dataType> <defaultValue></defaultValue> <shortCode>rxcode</shortCode> </stateVariable>

You create Trigger definitions with the eventList2 structure in the D_XXXX.json file.
This described what events your plugin will provide to the outside world.
They can be used as a Notification for your own plugin and/or a trigger for a scene or the PL Plugins
Look at existing files on your vera to get some examples.
I have include the DayOrNight Plugin’s event.

"eventList2": [
            "id": 1,
            "label": {
                "lang_tag": "toggle_day_night",
                "text": "Day or Night has arrived"
            "serviceId": "urn:rts-services-com:serviceId:DayTime",
            "argumentList": [
                    "id": 1,
                    "dataType": "boolean",
                    "defaultValue": "1",
                    "allowedValueList": [
                            "Off": "0",
                            "HumanFriendlyText": {
                                "lang_tag": "night",
                                "text": "_DEVICE_NAME_ indicates Night time."
                            "On": "1",
                            "HumanFriendlyText": {
                                "lang_tag": "day",
                                "text": "_DEVICE_NAME_ indicates Day time."
                    "name": "Status",
                    "comparisson": "=",
                    "prefix": {
                        "lang_tag": "which_mode",
                        "text": "Which mode"
                    "suffix": {}

This uses my Status variable with serviceid urn:rts-services-com:serviceId:DayTime


On this rare occasion, I got there first. ;D

And I noticed :wink:

Thank you very much!