|
1 |
| -<?xml version="1.0"?> |
2 |
| -<implementation> |
3 |
| - <functions> |
4 |
| - local p |
5 |
| - |
6 |
| - function startup(lul_device) |
7 |
| - luup.log("Arduino plugin: loading library L_Arduino ...") |
8 |
| - if (package.path:find ("/etc/cmh-ludl/?.lua;/etc/cmh-lu/?.lua", 1, true) == nil) then |
9 |
| - package.path = package.path .. ";/etc/cmh-ludl/?.lua;/etc/cmh-lu/?.lua" |
10 |
| - end |
11 |
| - |
12 |
| - package.loaded.L_Arduino = nil |
13 |
| - p = require("L_Arduino") |
14 |
| - if (package.loaded.L_Arduino == nil) |
15 |
| - then |
16 |
| - luup.log("Arduino plugin: plugin is not installed correctly. Library L_Arduino cannot be loaded.", 1) |
17 |
| - luup.task("Plugin not correctly installed", 2, "Arduino plugin", -1) |
18 |
| - return false |
19 |
| - end |
20 |
| - |
21 |
| - luup.log("Arduino plugin: library L_Arduino loaded") |
22 |
| - |
23 |
| - return p.startup(lul_device) |
24 |
| - end |
25 |
| - </functions> |
26 |
| - |
27 |
| - <incoming> |
28 |
| - <lua>if (p ~= nil) then p.processIncoming(lul_data) end</lua> |
29 |
| - </incoming> |
30 |
| - |
31 |
| - <startup>startup</startup> |
32 |
| - <actionList> |
33 |
| - <action> |
34 |
| - <serviceId>urn:upnp-org:serviceId:SwitchPower1</serviceId> |
35 |
| - <name>SetTarget</name> |
36 |
| - <run>if (p ~= nil) then p.switchPower(lul_device, lul_settings.newTargetValue) end</run> |
37 |
| - </action> |
38 |
| - <action> |
39 |
| - <serviceId>urn:upnp-org:serviceId:Dimming1</serviceId> |
40 |
| - <name>SetLoadLevelTarget</name> |
41 |
| - <run>if (p ~= nil) then p.setDimmerLevel(lul_device, lul_settings.newLoadlevelTarget) end</run> |
42 |
| - </action> |
43 |
| - <action> |
44 |
| - <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> |
45 |
| - <name>Up</name> |
46 |
| - <run>if (p ~= nil) then p.windowCovering(lul_device, "UP") end</run> |
47 |
| - </action> |
48 |
| - <action> |
49 |
| - <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> |
50 |
| - <name>Down</name> |
51 |
| - <run>if (p ~= nil) then p.windowCovering(lul_device, "DOWN") end</run> |
52 |
| - </action> |
53 |
| - <action> |
54 |
| - <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> |
55 |
| - <name>Stop</name> |
56 |
| - <run>if (p ~= nil) then p.windowCovering(lul_device, "STOP") end</run> |
57 |
| - </action> |
58 |
| - <action> |
59 |
| - <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> |
60 |
| - <name>SetArmed</name> |
61 |
| - <run>if (p ~= nil) then p.setArmed(lul_device, lul_settings.newArmedValue) end</run> |
62 |
| - </action> |
63 |
| - <action> |
64 |
| - <serviceId>urn:upnp-arduino-cc:serviceId:arduino1</serviceId> |
65 |
| - <name>SendCommand</name> |
66 |
| - <run>if (p ~= nil) then p.sendCommand(lul_settings.radioId, lul_settings.variableId, lul_settings.value) end</run> |
67 |
| - </action> |
68 |
| - <action> |
69 |
| - <serviceId>urn:upnp-arduino-cc:serviceId:arduinonode1</serviceId> |
70 |
| - <name>SendNodeCommand</name> |
71 |
| - <run>if (p ~= nil) then p.sendNodeCommand(lul_device, lul_settings.variableId, lul_settings.value) end</run> |
72 |
| - </action> |
73 |
| - |
74 |
| - <action> |
75 |
| - <serviceId>urn:upnp-arduino-cc:serviceId:arduinonode1</serviceId> |
76 |
| - <name>FetchChildren</name> |
77 |
| - <run>if (p ~= nil) then p.fetchChildren(lul_device) end</run> |
78 |
| - </action> |
79 |
| - |
80 |
| - <action> |
81 |
| - <serviceId>urn:upnp-arduino-cc:serviceId:arduinonode1</serviceId> |
82 |
| - <name>ClearChildren</name> |
83 |
| - <run>if (p ~= nil) then p.clearChildren(lul_device) end</run> |
84 |
| - </action> |
85 |
| - |
86 |
| - <action> |
87 |
| - <serviceId>urn:upnp-arduino-cc:serviceId:arduinonode1</serviceId> |
88 |
| - <name>RefreshRelay</name> |
89 |
| - <run>if (p ~= nil) then p.refreshRelay(lul_device) end</run> |
90 |
| - </action> |
91 |
| - |
92 |
| - <action> |
93 |
| - <serviceId>urn:upnp-arduino-cc:serviceId:arduino1</serviceId> |
94 |
| - <name>SetUnit</name> |
95 |
| - <run>if (p ~= nil) then p.setUnit(lul_settings.unit) end</run> |
96 |
| - </action> |
97 |
| - |
98 |
| - <action> |
99 |
| - <serviceId>urn:upnp-arduino-cc:serviceId:arduino1</serviceId> |
100 |
| - <name>StartInclusion</name> |
101 |
| - <run>if (p ~= nil) then p.startInclusion(lul_device) end</run> |
102 |
| - </action> |
103 |
| - <action> |
104 |
| - <serviceId>urn:upnp-arduino-cc:serviceId:arduino1</serviceId> |
105 |
| - <name>StopInclusion</name> |
106 |
| - <run>if (p ~= nil) then p.stopInclusion(lul_device) end</run> |
107 |
| - </action> |
108 |
| - |
109 |
| - |
110 |
| - |
111 |
| - <action> |
112 |
| - <serviceId>urn:upnp-org:serviceId:ArduinoIr1</serviceId> |
113 |
| - <name>SendIrCommand</name> |
114 |
| - <run>if (p ~= nil) then p.sendIrCommand(lul_device, lul_settings.irCodeNumber) end</run> |
115 |
| - </action> |
116 |
| - |
117 |
| - </actionList> |
118 |
| -</implementation> |
| 1 | +<?xml version="1.0"?> |
| 2 | +<implementation> |
| 3 | + <functions> |
| 4 | + local p |
| 5 | + |
| 6 | + function startup(lul_device) |
| 7 | + luup.log("Arduino plugin: loading library L_Arduino ...") |
| 8 | + if (package.path:find ("/etc/cmh-ludl/?.lua;/etc/cmh-lu/?.lua", 1, true) == nil) then |
| 9 | + package.path = package.path .. ";/etc/cmh-ludl/?.lua;/etc/cmh-lu/?.lua" |
| 10 | + end |
| 11 | + |
| 12 | + package.loaded.L_Arduino = nil |
| 13 | + p = require("L_Arduino") |
| 14 | + if (package.loaded.L_Arduino == nil) |
| 15 | + then |
| 16 | + luup.log("Arduino plugin: plugin is not installed correctly. Library L_Arduino cannot be loaded.", 1) |
| 17 | + luup.task("Plugin not correctly installed", 2, "Arduino plugin", -1) |
| 18 | + return false |
| 19 | + end |
| 20 | + |
| 21 | + luup.log("Arduino plugin: library L_Arduino loaded") |
| 22 | + |
| 23 | + return p.startup(lul_device) |
| 24 | + end |
| 25 | + </functions> |
| 26 | + |
| 27 | + <incoming> |
| 28 | + <lua>if (p ~= nil) then p.processIncoming(lul_data) end</lua> |
| 29 | + </incoming> |
| 30 | + |
| 31 | + <startup>startup</startup> |
| 32 | + <actionList> |
| 33 | + <action> |
| 34 | + <serviceId>urn:upnp-org:serviceId:SwitchPower1</serviceId> |
| 35 | + <name>SetTarget</name> |
| 36 | + <run>if (p ~= nil) then p.switchPower(lul_device, lul_settings.newTargetValue) end</run> |
| 37 | + </action> |
| 38 | + <action> |
| 39 | + <serviceId>urn:upnp-org:serviceId:Dimming1</serviceId> |
| 40 | + <name>SetLoadLevelTarget</name> |
| 41 | + <run>if (p ~= nil) then p.setDimmerLevel(lul_device, lul_settings.newLoadlevelTarget) end</run> |
| 42 | + </action> |
| 43 | + <action> |
| 44 | + <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> |
| 45 | + <name>Up</name> |
| 46 | + <run>if (p ~= nil) then p.windowCovering(lul_device, "UP") end</run> |
| 47 | + </action> |
| 48 | + <action> |
| 49 | + <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> |
| 50 | + <name>Down</name> |
| 51 | + <run>if (p ~= nil) then p.windowCovering(lul_device, "DOWN") end</run> |
| 52 | + </action> |
| 53 | + <action> |
| 54 | + <serviceId>urn:upnp-org:serviceId:WindowCovering1</serviceId> |
| 55 | + <name>Stop</name> |
| 56 | + <run>if (p ~= nil) then p.windowCovering(lul_device, "STOP") end</run> |
| 57 | + </action> |
| 58 | + <action> |
| 59 | + <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId> |
| 60 | + <name>SetArmed</name> |
| 61 | + <run>if (p ~= nil) then p.setArmed(lul_device, lul_settings.newArmedValue) end</run> |
| 62 | + </action> |
| 63 | + <action> |
| 64 | + <serviceId>urn:upnp-arduino-cc:serviceId:arduino1</serviceId> |
| 65 | + <name>SendCommand</name> |
| 66 | + <run>if (p ~= nil) then p.sendCommand(lul_settings.radioId, lul_settings.variableId, lul_settings.value) end</run> |
| 67 | + </action> |
| 68 | + <action> |
| 69 | + <serviceId>urn:upnp-arduino-cc:serviceId:arduinonode1</serviceId> |
| 70 | + <name>SendNodeCommand</name> |
| 71 | + <run>if (p ~= nil) then p.sendNodeCommand(lul_device, lul_settings.variableId, lul_settings.value) end</run> |
| 72 | + </action> |
| 73 | + |
| 74 | + <action> |
| 75 | + <serviceId>urn:upnp-arduino-cc:serviceId:arduinonode1</serviceId> |
| 76 | + <name>FetchChildren</name> |
| 77 | + <run>if (p ~= nil) then p.fetchChildren(lul_device) end</run> |
| 78 | + </action> |
| 79 | + |
| 80 | + <action> |
| 81 | + <serviceId>urn:upnp-arduino-cc:serviceId:arduinonode1</serviceId> |
| 82 | + <name>ClearChildren</name> |
| 83 | + <run>if (p ~= nil) then p.clearChildren(lul_device) end</run> |
| 84 | + </action> |
| 85 | + |
| 86 | + <action> |
| 87 | + <serviceId>urn:upnp-arduino-cc:serviceId:arduinonode1</serviceId> |
| 88 | + <name>RefreshRelay</name> |
| 89 | + <run>if (p ~= nil) then p.refreshRelay(lul_device) end</run> |
| 90 | + </action> |
| 91 | + |
| 92 | + <action> |
| 93 | + <serviceId>urn:upnp-arduino-cc:serviceId:arduino1</serviceId> |
| 94 | + <name>SetUnit</name> |
| 95 | + <run>if (p ~= nil) then p.setUnit(lul_settings.unit) end</run> |
| 96 | + </action> |
| 97 | + |
| 98 | + <action> |
| 99 | + <serviceId>urn:upnp-arduino-cc:serviceId:arduino1</serviceId> |
| 100 | + <name>StartInclusion</name> |
| 101 | + <run>if (p ~= nil) then p.startInclusion(lul_device) end</run> |
| 102 | + </action> |
| 103 | + <action> |
| 104 | + <serviceId>urn:upnp-arduino-cc:serviceId:arduino1</serviceId> |
| 105 | + <name>StopInclusion</name> |
| 106 | + <run>if (p ~= nil) then p.stopInclusion(lul_device) end</run> |
| 107 | + </action> |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + <action> |
| 112 | + <serviceId>urn:upnp-org:serviceId:ArduinoIr1</serviceId> |
| 113 | + <name>SendIrCommand</name> |
| 114 | + <run>if (p ~= nil) then p.sendIrCommand(lul_device, lul_settings.irCodeNumber) end</run> |
| 115 | + </action> |
| 116 | + |
| 117 | + </actionList> |
| 118 | +</implementation> |
0 commit comments