First of all, create two new virtual devices for your motion sensor and light sensor. You can do it under Apps, Develop Apps, Create Device.
Light Sensor:
- DeviceType: urn:schemas-micasaverde-com:device:LightSensor:1
- Upnp Device Filename: D_LightSensor1.xml
- device_json: D_LightSensor1.json
Motion Sensor:
- DeviceType: urn:schemas-micasaverde-com:device:MotionSensor:1
- Upnp Device Filename: D_MotionSensor1.xml
- device_json: D_MotionSensor1.json
wait for luup engine to reload every time you create a new virtual device. Note down all the three IDs.
then place this code in your startup luup code:
-- change to yours
local masterID = 666
local sensorID = 667
local lightID = 668
function copyVariable(dev_id, service, variable, oldValue, newValue)
if tonumber(oldValue) ~= tonumber(newValue) then
local deviceID = variable == "CurrentLevel" and lightID or sensorID
luup.variable_set(service, variable, newValue, deviceID)
end
end
luup.variable_watch("copyVariable", "urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", masterID)
luup.variable_watch("copyVariable", "urn:micasaverde-com:serviceId:LightSensor1", "CurrentLevel", masterID)