diff --git a/vera/I_DiySomfy1.xml b/vera/I_DiySomfy1.xml --- a/vera/I_DiySomfy1.xml +++ b/vera/I_DiySomfy1.xml @@ -1,79 +1,85 @@ function lug_startup (lul_device) ipAddress = luup.devices[lul_device].ip local blindIds = luup.variable_get( "urn:micasaverde-com:serviceId:DiySomfy1", "BlindIds", lul_device) or "" if (blindIds == "") then blindIds = "1,2" luup.variable_set( "urn:micasaverde-com:serviceId:DiySomfy1", "BlindIds", blindIds, lul_device) end if (ipAddress == "") then luup.log("No ip address for Somfy", 1) return false, "Set up the IP address for Somfy", "Somfy DiY Blind Interface" end luup.log( "Somfy channels are '" .. blindIds) local childDevices = luup.chdev.start(lul_device) for blindNo in blindIds:gmatch("%d") do luup.log( "Adding blind #" .. blindNo ..".") luup.chdev.append( lul_device, childDevices, blindNo, "Blind #"..blindNo, "urn:schemas-micasaverde-com:device:WindowCovering:1", "D_WindowCovering1.xml", "", "", false) end luup.chdev.sync(lul_device, childDevices) end lug_startup local response = tostring(lul_data) luup.log("Response:" .. response) urn:upnp-org:serviceId:WindowCovering1 Up + local http = require("socket.http") + http.TIMEOUT = 60 ipAddress = luup.devices[luup.devices[lul_device].device_num_parent].ip local lul_command = "http://" .. ipAddress .. "/" .. luup.devices[lul_device].id .. "/up" - if(luup.inet.wget(lul_command, 60) ~= 0) then + if(http.request(lul_command) == nil) then luup.log( "Cannot send '" .. tostring(lul_command) .. "'.", 1) luup.set_failure(true) return false end urn:upnp-org:serviceId:WindowCovering1 Down + local http = require("socket.http") + http.TIMEOUT = 60 ipAddress = luup.devices[luup.devices[lul_device].device_num_parent].ip local lul_command = "http://" .. ipAddress .. "/" .. luup.devices[lul_device].id .. "/down" - if(luup.inet.wget(lul_command, 60) ~= 0) then + if(http.request(lul_command) == nil) then luup.log( "Cannot send '" .. tostring(lul_command) .. "'.", 1) luup.set_failure(true) return false end urn:upnp-org:serviceId:WindowCovering1 Stop + local http = require("socket.http") + http.TIMEOUT = 60 ipAddress = luup.devices[luup.devices[lul_device].device_num_parent].ip local lul_command = "http://" .. ipAddress .. "/" .. luup.devices[lul_device].id .. "/stop" - if(luup.inet.wget(lul_command, 60) ~= 0) then + if(http.request(lul_command) == nil) then luup.log( "Cannot send '" .. tostring(lul_command) .. "'.", 1) luup.set_failure(true) return false end