I’m trying to reproduce Somfy device, and while all the code runs OK within Test Luup Code context, the same code placed into Luup XMLs doesn’t seems to be invoked ever. I realized that by seeng none of my debug prints, and after I “removed” child nodes from Test Luup Code - they never re-appeared after restart even though startup code is there.
<root>
−
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
−
<device>
<deviceType>urn:somfy-com:device:blinds:1</deviceType>
<friendlyName>Somfy Blind Controller</friendlyName>
<manufacturer>Somfy</manufacturer>
<manufacturerURL>http://www.somfy.com</manufacturerURL>
<modelDescription>16 port RS232 to Somfy blind interface</modelDescription>
<modelName>1810686</modelName>
<modelNumber>1.0</modelNumber>
<protocol>raw</protocol>
<handleChildren>1</handleChildren>
−
<implemenationList>
<implementationFile>I_SomfyBlinds.xml</implementationFile>
</implemenationList>
<presentationURL/>
</device>
</root>
<implementation>
−
<settings>
<protocol>crlf</protocol>
</settings>
−
<functions>
function lug_startup(lul_device)
local lul_ID = lug_device[lul_device].ID
lu_log("ID is " .. lul_ID)
child_devices = lu_chdev_start(lul_device);
for i=1,16 do
s=string.format("%02d", i)
if( string.find (lul_ID,s)~=nill ) then
lu_log("Adding blind "..s)
lu_chdev_append(lul_device,child_devices,s,"Blind #"..s,"urn:schemas-upnp-org:device:BinaryLight:1","","","",true)
end
end
lu_chdev_sync(lul_device,child_devices)
end
</functions>
−
<incoming>
−
<lua>
lu_log("Received: " .. tostring(lul_data))
</lua>
</incoming>
<startup>
lug_startup
</startup>
−
<actionList>
−
<action>
<serviceId>urn:upnp-org:serviceId:SwitchPower1</serviceId>
<name>SetTarget</name>
−
<run>
lu_log("DDDDDDDD")
local lul_command = '!' .. lug_device[lul_device].ID .. 'U'
local lul_reverse = lu_GetVariable("urn:micasaverde-com:serviceId:HaDevice1","ReverseOnOff",lul_device)
if( lul_settings.newTargetValue=="1" or (lul_settings.newTargetValue=="0" and lul_reverse=="1") ) then
lul_command = '!' .. lug_device[lul_device].ID .. 'D'
end
lu_log(">>>>>>>>>>>>trying to send the command: " .. tostring(lul_command),1)
if lu_iop_send(lul_command)==false then
lu_log("cannot send: " .. tostring(lul_command),1)
lu_SetCommFailure(true)
return false
end
</run>
</action>
</actionList>
</implementation>