in my IPhoneLocator plugin I am trying to enumerate devices from a iCloud account and create devices accordingly. That code below works and it does create the child devices properly, with the right dashboard/json etc , but it seems the startup method of the child device is never called
The D_ and I_ file of parent and child is the same , but in the initialisation I of course take care of not creating child devices when I am already in a child device ( parent != 0 )
I do not want to use 1 as the purpose is to have each child device living their independant life from the parent…
I also tried with the “embedded” parameter at true or false in the luup.chdev.append() api with no luck.
I saw @lolodomo struggled a bit in the past with that as well but did not see a conclusion to the thread.
Help would be greatly appreciated.
Line 2307: 50 10/05/13 12:28:20.101 luup_log:83: IPhoneLocator: startupDeferred __LEAK__ this:258048 start:1417216 to 0x1000000 <0x2dfcb680>
Line 2316: 50 10/05/13 12:28:20.104 luup_log:84: IPhoneLocator: startupDeferred <0x2e1cb680>
Line 2410: 50 10/05/13 12:28:23.595 luup_log:83: IPhoneLocator: debug: startup completed for root device <0x2dfcb680>
Line 2437: 50 10/05/13 12:28:23.706 luup_log:84: IPhoneLocator: debug: startup completed for root device <0x2e1cb680>
function initstatus(lul_device)
lul_device = tonumber(lul_device)
log("starting version "..version)
if (luup.devices[lul_device].device_num_parent==0) then
debug("initstatus for Root device")
else
debug("initstatus for Child device")
end
luup.call_delay("startupDeferred", 1, tostring(lul_device))
end
[code]function createChildDevices(lul_device)
lul_device = tonumber(lul_device)
log(“createChildDevices()”)
local email = luup.variable_get(service,“Email”, lul_device)
local password = luup.variable_get(service,“Password”, lul_device)
local mydevice = luup.variable_get(service,“IPhoneName”, lul_device)
local devicemap = getAppleDeviceMap(email, password)
local child_devices = luup.chdev.start(lul_device);
for key,value in pairs(devicemap) do
local devicename = string.match(value.name,mydevice)
if (devicename~=nil) then
debug(string.format("value.name:%s mydevice:%s match:%s",value.name,mydevice,devicename))
luup.chdev.append(
lul_device, child_devices, -- parent device and handle
"child_"..devicename, devicename, -- id and description
service, -- device type
"D_IPhone.xml", "I_IPhone.xml", -- device filename and implementation filename
"", -- uPNP child device parameters: "service,variable=value\nservice..."
false, -- embedded
false -- invisible
)
else
debug(string.format("value.name:%s mydevice:%s no match",value.name,mydevice))
end
end
luup.chdev.sync(lul_device, child_devices)
end[/code]