1.0.3 • Published 2 years ago

loewe.js v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Loewe.js API wrapper

Hey, this is a simple wrapper for the Loewe SOAP API. It's not complete, but it's enough for my needs. Feel free to contribute.

Please note, that the code is mostly auto-generated by wsdl-tsclient, but modified by hand to make it work better using the Loewe SOAP API, as it often handles a bit difficult!

Disclaimer

I am already coding for about 4 years, but this is my first published library / SDK - so feel free to contribute and improve it - also concerning readability and code quality in libraries, as I am not that experienced in Module / SDK development :)

Usage

Installation

npm install loewe-js

In order to use the library, you first have to download the WSDL file from your TV. It is located here: http://:905/lowew_tablet_0001?wsdl Alternatively, you can use the WSDL file from this repository, but it might be outdated. (loewe didn't change it since 2018, so feel free :)

Quick dive into the Loewe API

The Loewe API is no API, you love to use - but I want to make you have a best experience using it! (at least as far as it's possible ;)

This ist the API Flow: 1. Send a login request: Call RequestAuth with the needed parameters (see tabcompletion or typing files), but put ? as the ClientId 2. Receive the new ClientId. Note, that the AccessStatus value currently is Pending. 3. Wait some seconds and call RequestAuth again with the same parameters, but now with the ClientId you received in step 2. 4. Receive the Response containing the same information except, the AccessStatus value is now Accepted.

You can now use the ClientId and fcid for further requests. It's not clear how long the ClientId is valid. I experienced a lifetime of the time while the TV isn't restarted (standby ok, but no deep-sleep), but docs are saying "until the TV needs resources and cancels the ClientId".

Hints on the Credentials: The fcid is like a username. The ClientId is like a token. DeviceType can be selected freely. DeviceName can be selected freely. DeviceUUID should be a MAC-Address like string RequesterName can be selected freely.

Example

import { createClientAsync } from 'loewe-js';
const authData = {
    fcid: "fcid",
    DeviceType: "deviceType",
    DeviceName: "deviceName",
    DeviceUUID: "deviceUUID",
    RequesterName: "requesterName",
    ClientId: "?"
}

createClientAsync("path/to/wsdl.wsdl", {
    endpoint: "http://<ip-of-tv>:905/loewe_tablet_0001"
})
.then(c => {
    c.RequestAccess(authData)
        .then(authResponse => {
            const clientId = authResponse[0].ClientId;
            // send further requests with the clientId
        })
})

The response data is serialized to JSON, so you can use it directly. It's located inside the first array element.

FAQ

How do I implement an array of e.g. RCKeys?

I just had the same problem ;) I haven't known much about SOAP myself, so I found out, there's an easy way. Look at the demo.ts file in this packages directory. Important are: 1. the namespaceArrayElements: false option in the createClientAsync call 2. the InputEventSequence with its Array of XML nodes containing the attributes defining the RCKey

looks a bit difficult or annoying - but works completely fine with the built-in serializer!

Contribution

Feel free to contribute to this project. Just fork it and create a pull request. Any Bugfixes or new features are welcome.