Changeset 220
- Timestamp:
- 2014-11-13 00:25:18 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/ipx800/L_IPX800.lua ¶
r219 r220 209 209 210 210 function updateDevice(lul_device, xmldata) 211 lul_device = tonumber(lul_device) 211 212 log(string.format("updateDevice(%d)",lul_device)) 212 213 … … 225 226 luup.variable_set(service, "Present", "1", lul_device) 226 227 luup.variable_set(service, "IconCode", "100", lul_device) 227 end 228 return lomtab 229 end 230 return nil 231 end 232 233 function updateChildrenDevice(lul_device, lomtab) 234 lul_device = tonumber(lul_device) 235 log(string.format("updateChildrenDevice(%d)",lul_device)) 236 237 -- for all children device, iterate 238 local param = {} 239 for k,v in pairs(luup.devices) do 240 if( getParent(k)==lul_device) then 241 -- find the altid 242 local name = v.id 243 debug(string.format("device altid=%s",name)) 244 -- find the xml node with the same name 245 -- read the value 246 local led = xpath.selectNodes(lomtab,"/response/"..name.."/text()") 247 debug(string.format("xml %s value=%s",name, led[1])) 248 -- set the power value 249 setPowerTarget(k,led[1]) 250 end 251 end 252 228 253 end 229 254 … … 306 331 307 332 local xmldata = getGlobalStatus(lul_device,ipxIpAddress,user,password) 308 updateDevice(lul_device, xmldata) 309 333 local lomtab = updateDevice(lul_device, xmldata) 334 if (lomtab~=nil) then 335 updateChildrenDevice(lul_device, lomtab) 336 end 310 337 -- repeat every x seconds 311 338 if (updateFrequencySec>0) and (norepeat~=true) then … … 320 347 function createChildDevices(lul_device) 321 348 lul_device = tonumber(lul_device) 322 349 log("createChildDevices, called on behalf of device:"..lul_device) 350 local outputRelays = getSetVariable(service,"OutputRelays", lul_device, "") or "" 351 323 352 -- for now , just test with one device 324 353 local child_devices = luup.chdev.start(lul_device); 325 luup.chdev.append( 326 lul_device, child_devices, 327 "led0", "IPX Out 0", 328 "urn:schemas-upnp-org:device:BinaryLight:1","D_BinaryLight1.xml", 329 "", "", 330 true -- embedded 331 ) 354 355 for k,v in pairs(outputRelays:split(",")) do 356 local i = tonumber(v) 357 if (i>=1) and (i<=32) then 358 debug(string.format("Creating device for output relay:%d",i)) 359 luup.chdev.append( 360 lul_device, child_devices, 361 "led"..(i-1), "IPX800 Out "..i, 362 "urn:schemas-upnp-org:device:BinaryLight:1","D_BinaryLight1.xml", 363 "", "", 364 true -- embedded 365 ) 366 end 367 end 368 332 369 luup.chdev.sync(lul_device, child_devices) 333 370 end … … 346 383 local password= getSetVariable(service,"Password", lul_device, "") 347 384 local updateFrequencySec= getSetVariable(service,"UpdateFrequency", lul_device, 60) 385 local outputRelays= getSetVariable(service,"OutputRelays", lul_device, "") 348 386 349 387 if (debugmode=="1") then … … 370 408 end 371 409 410 createChildDevices(lul_device) 411 372 412 -- start refreshes , with repeat 373 413 refreshDevice(lul_device,false) 374 414 375 createChildDevices(lul_device)376 415 end 377 416
Note: See TracChangeset
for help on using the changeset viewer.