Script for Discovery and Controll of Wemo Switches
Posted: Saturday 17 September 2016 14:07
Hi All,
I've been playing with a few of my WeMo switches, I've recompiled and fixed a Java applet (This one) -> https://objectpartners.com/2014/03/25/a ... -and-wemo/
and re-written the script in the Wiki into PHP. the result is that I can now discover and refer to Wemo devices by Name. I've attached the script but not the jar if anyone wants it I will need to figure out somewhere to host it too big for this board ! As it stands the one above will not find any updated belkins.
to fix this under /wemocontrol/src/UpnpDiscovery.groovy
Around Line 83
change "packet.append( "ST: " ).append( "ssdp:all" ).append( "\r\n" ).append( "\r\n" )" to packet.append( "ST: " ).append( "urn:Belkin:service:basicevent:1" ).append( "\r\n" ).append( "\r\n" )
Around Line 62
change if (originaldata.contains("urn:Belkin:device:controllee") || originaldata.contains("urn:Belkin:device:lightswitch")) to
if (originaldata.contains("urn:Belkin:service:basicevent:1")
This is totally not Prod worthy but what is does it is.
1. Check to see if it has refereed to the Wemo before ( looks in /tmp for a file )
2. if not starts a discovery and finds the Wemo ( Or bombs out telling you to plug it in )
3. then when it has found the Wemo it checks to see if this is the right Wemo if not See step 2
4. Runs one of the actions On/off/status/signal (although the last two don't output anything as yet !) the returned XML is Bonkers !
Please excuse my puns and random comments in the script....
Ok I have created my own branch in GIT for this https://github.com/jnex26/WemoControlandDiscovery
I've been playing with a few of my WeMo switches, I've recompiled and fixed a Java applet (This one) -> https://objectpartners.com/2014/03/25/a ... -and-wemo/
and re-written the script in the Wiki into PHP. the result is that I can now discover and refer to Wemo devices by Name. I've attached the script but not the jar if anyone wants it I will need to figure out somewhere to host it too big for this board ! As it stands the one above will not find any updated belkins.
to fix this under /wemocontrol/src/UpnpDiscovery.groovy
Around Line 83
change "packet.append( "ST: " ).append( "ssdp:all" ).append( "\r\n" ).append( "\r\n" )" to packet.append( "ST: " ).append( "urn:Belkin:service:basicevent:1" ).append( "\r\n" ).append( "\r\n" )
Around Line 62
change if (originaldata.contains("urn:Belkin:device:controllee") || originaldata.contains("urn:Belkin:device:lightswitch")) to
if (originaldata.contains("urn:Belkin:service:basicevent:1")
This is totally not Prod worthy but what is does it is.
1. Check to see if it has refereed to the Wemo before ( looks in /tmp for a file )
2. if not starts a discovery and finds the Wemo ( Or bombs out telling you to plug it in )
3. then when it has found the Wemo it checks to see if this is the right Wemo if not See step 2
4. Runs one of the actions On/off/status/signal (although the last two don't output anything as yet !) the returned XML is Bonkers !
Please excuse my puns and random comments in the script....
Ok I have created my own branch in GIT for this https://github.com/jnex26/WemoControlandDiscovery