Using cling with Belkin Wemo

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Using cling with Belkin Wemo

Philipp Hug
Hi,

I tried to use cling with the Belkin Wemo, but unfortunately Wemo has some bugs.
Here's a list of them:
* mime-type of icon is 'jpg' instead of 'image/jpeg'
* one of the scpd files start with a UTF-8 BOM (byte-order-mark) which is not recommended and cling doesn't like it.
* the scpd files are completely inconsistent: e.g variables not declared, or multiple values defined as retval. here's some output:
- Only one argument of action 'ShareHWInfo' can be <retval/>
- Only one argument of action 'SetMultiState' can be <retval/>
 Only one argument of action 'SetLogLevelOption' can be <retval/>
- Only one argument of action 'ChangeDeviceIcon' can be <retval/>
- Only one argument of action 'GetServerEnvironment' can be <retval/>
- Argument 'ServerEnvironmentType' of action 'GetServerEnvironment' is <retval/> but not the first OUT argument
* in one of the scpd files, the argumentList misses the argument element. Good thing here is, that I don't need that one

So to make it work, I had to patch cling.
Is there a possibility to change the official cling source to:
a) make it possible to disable verification
b) accept XML files with UTF-8 BOM (byte-order-mark)
c) only warn, when mime type is not valid instead of throwing an exception

Or is there another way to fix this? e.g. preprocessing of the scpd files?

Philipp
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

Christian Bauer
Administrator
Fork and pull request on github.
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

miked
In reply to this post by Philipp Hug
Is your patch / code changes available anywhere?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

gitaaronc
In reply to this post by Philipp Hug
Can you share your solution?

Also using the ControlPoint.search function I am unable to find the WeMo using the Belkin namespace.

DeviceType myDeviceType = new DeviceType("Belkin", "controllee", 1);
upnpService.getCtonrolPoint().search(new DeviceTypeHeader(myDeviceType));

The device is never returned to my RegistryListener.

Thanks,

Aaron
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

gitaaronc
Hi,

The Belkin WEMO Upnp stack is broken.

I've created a custom UpnpServiceConfiguration and over ride a few fuctions in hopes that i could over come the Belkin issues.

                class myUpnpServiceConfiguration extends
                                DefaultUpnpServiceConfiguration {

                        @Override
                        public Namespace createNamespace() {
                                return new Namespace("Belkin:device-1-0"); ?? Tried just "Belkin" and several other names
                        }

                        @Override
                        public SOAPActionProcessor getSoapActionProcessor() {
                                return new PullSOAPActionProcessorImpl();
                        }

                }
Unfortunately this isn't working for me.

Could somebody point me in the right direction to overcome the following errors?

Dec 14, 2013 8:17:31 AM org.fourthline.cling.binding.xml.UDA10DeviceDescriptorBinderImpl hydrateRoot
WARNING: Wrong XML namespace declared on root element: urn:Belkin:device-1-0
Dec 14, 2013 8:17:31 AM org.fourthline.cling.protocol.RetrieveRemoteDescriptors describe

Something other than RTFM please, I've been doing that already. :0

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

gitaaronc
Well I figured it out and as suspected the Belkin Wemo upnp stack is a pos.

I extended the DefaultUpnpServiceConfiguration, cobbled together a DeviceDescriptor and a ServiceDescriptor.

                class myUpnpServiceConfiguration extends
                                DefaultUpnpServiceConfiguration {

                        @Override
                        public DeviceDescriptorBinder getDeviceDescriptorBinderUDA10(){
                                return new myDeviceDescriptorBinderSAXImpl();
                                //return new RecoveringUDA10DeviceDescriptorBinderImpl();
                        }
                        @Override
                        public ServiceDescriptorBinder getServiceDescriptorBinderUDA10(){
                                return new myServiceDescriptorBinderSAXImpl();
                                //return new UDA10ServiceDescriptorBinderImpl();
                        }
                       
                        /*
                        @Override
                        public Namespace createNamespace() {
                                return new Namespace("Belkin");
                        }
                        */

                }

Unfortunately the cling library is far to well written and adheres to the Upnp protocol.
After successfully parsing the device, I then had problems with the services. Lots of problems.
There are far to many relatedStateVariable elements with no matching stateVariables to deal with.

In the end, I either have to give up on Belkin or pair it up with a pos Upnp library.

Any other suggestions?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

gitaaronc
Well, I'm not a Java programmer but I managed to learn a lot about the cling library and Java. I have managed to cobble together enough code to successfully implement a "Belkin Wemo Switch" binding for Openhab. Once I am happy with the code, I'll share it with the world. lol
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

MikeD
I too have a working solution that involves (as an option/flag) setting cling to be more lenient in parsing services so it will accept the non-compliant junk Wemo puts out.  I have successfully operated my Wemo plug in switch.
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

gitaaronc
It would be nice to have that option in the library itself. Which it sounds like you are doing. I didn't want to rewrite the library though. So instead I opted to extend the existing classes and use them in my openhab binding. I'll put it on github over the next couple of days. Curious to see what you have done. Any chance you could put your code online somewhere?

Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

Philipp Hug
Hi,

Sorry for the delay. I hoped I would find time to clean this up before
I upload it, but this didn't happen.
So I'll just put it on for download in hope someone can clean it up
and release it.

Cling Patch:
* Ugly hack to not crash on missing Icon and not verififying schema.
* this needs to be cleaned up into a mergable patch for upstream
http://people.debian.org/~hug/cling-1.0.5-source-wemo.patch

Openhab wemo binding:
* copy-paste of sonos binding, needs to be cleaned up and copyright
headers adapted.
http://people.debian.org/~hug/org.openhab.binding.wemo.tar.gz

My changes are licensed under the same license as the corresponding
original code.

And sorry again for not taking care of it myself...
Philipp

On Thu, Dec 19, 2013 at 8:09 PM, gitaaronc [via Mailinglists]
<[hidden email]> wrote:

> It would be nice to have that option in the library itself. Which it sounds
> like you are doing. I didn't want to rewrite the library though. So instead
> I opted to extend the existing classes and use them in my openhab binding.
> I'll put it on github over the next couple of days. Curious to see what you
> have done. Any chance you could put your code online somewhere?
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://mailinglists.945824.n3.nabble.com/Using-cling-with-Belkin-Wemo-tp4025834p4026012.html
> To unsubscribe from Using cling with Belkin Wemo, click here.
> NAML
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

Christian Bauer
Administrator
It doesn't make much sense to patch Cling 1.0.5. In the 2.0 branch there is plenty of infrastructure for handling misbehaving devices, with lenient and recovering parsers and many test cases that can easily be extended. Off the top of my head, the icon issue has already been addressed as well.

Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

Philipp Hug
Hi Christian,

Exactly, the Sonos binding was using cling 1.0.5, so that's what I
used and patched.
The patch needs to be updated for the 2.0 branch and the the openhab
code might need some changes too.

Philipp

On Fri, Dec 20, 2013 at 12:27 AM, Christian Bauer [via Mailinglists]
<[hidden email]> wrote:

> It doesn't make much sense to patch Cling 1.0.5. In the 2.0 branch there is
> plenty of infrastructure for handling misbehaving devices, with lenient and
> recovering parsers and many test cases that can easily be extended. Off the
> top of my head, the icon issue has already been addressed as well.
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://mailinglists.945824.n3.nabble.com/Using-cling-with-Belkin-Wemo-tp4025834p4026014.html
> To unsubscribe from Using cling with Belkin Wemo, click here.
> NAML
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

gitaaronc
I haven't ried your patch yet, but I did try the cling 2.0 library before I extended the class of cling 1.0.5. The cling library fails on on the Belin icon mime/type "jpg" instead of "jpeg". Also there are 30 or 40 relatedStateVariables in the Belkin stack that do not have associated StateVariables. Rather than mess with a good thing (cling). I opted to extend the SaxImpl device and service class. Admittedly it is cobbled together code. As I mentioned I'm not a java programmer. I bought a wemo switch and have a Nexus 7, the belkin app didn't work on it. So I side loaded it, it was flaky. So I found openhab, but no binding. So I did what I could...

Here it is on github. https://github.com/gitaaronc/wemobinding
I would be happy to learn from anybody willing to take a look at it.


Thanks,

Aaron C.
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

gitaaronc
I should mention that it works well and clean.
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Belkin Wemo

gitaaronc