Jump to content
C4 Forums | Control4

Free WeMo Code tidbits


THEORY

Recommended Posts

Not sure if Composer HE allows the execution of LUA code on a driverworks driver. But here is some info from the Dealer forums regarding the WeMo. Does exactly what some other drivers out there do, although it shows it does make $75 a bit step for device that costs $49.99

This was posted by "TheWizard"

You can copy this into a lua window and execute it to watch your WeMo turn on/off, just change <SOME IP> to the IP of the WeMo (ex. '192.168.1.5'), and uncomment TurnOff or TurnOn (remove the "--" infront) to run that action.

function SendMessage(ip, port, endpoint, service, action, args) 
args = args or ''

-- Create our soap body
local body = ''
body = body .. '<?xml version="1.0" encoding="utf-8"?>'
body = body .. '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
body = body .. '<s:Body>'
body = body .. '<u:' .. action .. ' xmlns:u="urn:Belkin:service:' .. service .. ':1">'
body = body .. args
body = body .. '</u:' .. action .. '>'
body = body .. '</s:Body>'
body = body .. '</s:Envelope>'

-- Specify our headers.
local headers = {
["Connection"] = "close", -- Close connection after we have sent the message
["Content-Type"] = 'text/xml;', -- Sending XML
["Content-Length"] = #body, -- Length of our body
['SOAPACTION'] = '"urn:Belkin:service:' .. service .. ':1#' .. action.. '"' -- Specify the action
}

return C4:urlPost(string.format("http://%s:%s%s", ip, port, endpoint), body, headers)
end

-- Turn on WeMo device
function TurnOn(ip, port)
return SendMessage(ip, port, '/upnp/control/basicevent1', 'basicevent1', 'SetBinaryState', '<BinaryState>1</BinaryState>') -- State 1 (ON)
end

-- Turn off WeMo device
function TurnOff(ip, port)
return SendMessage(ip, port, '/upnp/control/basicevent1', 'basicevent1', 'SetBinaryState', '<BinaryState>0</BinaryState>') -- State 0 (OFF)
end

-- To turn on
-- TurnOn(<SOME IP>, '49153')

-- To turn off
-- TurnOff(<SOME IP>, '49153')

Link to comment
Share on other sites


^ No I'm talking about the code in the Belkin..not C4. :)

See http://www.c4forums.com/viewtopic.php?id=13920

This thing's wireless network configuration is just too hands off for me..

Fine if you are Apple and can just make "networking things" work...

But Belkin has never been Apple. So why try to fully automate the networking steps if you can't even sort out the device to run with all the available security wifi settings out there..

I mean when was the last time you had to re-congigure your wifi router just to get a wireless device to join your network and get a dedicated IP address?...

Link to comment
Share on other sites

I mean this is BS stuff it really is..

If you are going to release a wireless device onto the market at least make sure it works with all the available wireless security settings in the commonly available routers out there..

What a heep a &(*&()*

I hate it when tech companies do this..

Dear Belkin. Please product test things yourself properly, before releasing it to the market.... :)

And if you don't do this, then at least have a forum like this to help sort issues.... ;) LOL!

Link to comment
Share on other sites

Really?

Your not sure composer HE allows LUA code to be executed???

Download it and try it.

Or maybe just say what ytou mean

How about I mean I don't use HE, so I don't know what tabs are there or not. I don't care to try it to be honest as I program with Composer Pro.

Link to comment
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.