MagentaTV Binding for Deutsche Telekom MR 4xx

I uploaded a new build
https://github.com/markus7017/org.openhab.binding.entertaintv/blob/beta1/target/org.openhab.binding.entertaintv-2.4.0-SNAPSHOT.jar

  • fixes the volume up/down problem
  • the binding renews the subscription of the event channel every 5min and the pairing every 10min
  • adjusted some debug messages

@ibot1989 Please verify if this fixes you “runs only for 30min problem”. I may add a config option to adjust intervals, but for a first test this should be ok.

Hello Markus,

i have running the new version from GIT.
In the quick test it just looks good:

2018-10-23 22:25:57.600 [DEBUG] [.internal.handler.EntertainTVHandler] - EntertainTV: Check receiver status
2018-10-23 22:25:57.604 [DEBUG] [ertaintv.internal.EntertainTVControl] - EntertainTV: Subscribe Paring Channel (192.168.9.139:8081)
2018-10-23 22:25:57.607 [TRACE] [ertaintv.internal.EntertainTVNetwork] - EntertainTVNetwork: Sending data to '192.168.9.139:8081': 'SUBSCRIBE /upnp/service/X-CTC_RemotePairing/Event HTTP/1.1
HOST: 192.168.9.139:8081
CALLBACK: <http://192.168.9.20:8080/entertaintv/notify>
NT: upnp:event
TIMEOUT: Second-300
CONNECTION: close

'
2018-10-23 22:25:58.113 [TRACE] [ertaintv.internal.EntertainTVNetwork] - receiver response='HTTP/1.1 200 OK
DATE: Tue, 23 Oct 2018 20:25:57 UTC
Content-Length:0
SID: uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
TIMEOUT: Second-300
Connection: close

'
2018-10-23 22:25:58.122 [DEBUG] [ertaintv.internal.EntertainTVControl] - EntertainTV: SUBSCRIBE returned SID 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
2018-10-23 22:25:58.127 [DEBUG] [ertaintv.internal.EntertainTVControl] - EntertainTV: Renew pairing code
2018-10-23 22:25:58.132 [INFO ] [ertaintv.internal.EntertainTVControl] - EntertainTVControl: Send Pairing Request (firendlyName='PAD:openHAB', deviceID='26A5F0FD7A02C93E07CFC428C499D182', userID='93156XXXXXXF99')
2018-10-23 22:25:58.138 [TRACE] [ertaintv.internal.EntertainTVNetwork] - EntertainTVNetwork: POST 'http://192.168.9.139:8081/upnp/service/X-CTC_RemotePairing/Control' - SoapAction='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X-pairingRequest xmlns:u="urn:schemas-upnp-org:service:X-CTC_RemotePairing:1"><pairingDeviceID>26A5F0FD7A02C93E07CFC428C499D182</pairingDeviceID><friendlyName>PAD:openHAB</friendlyName><userID>93156XXXXXXXXXXF99</userID></u:X-pairingRequest></s:Body></s:Envelope>', Data = '"urn:schemas-upnp-org:service:X-CTC_RemotePairing:1#X-pairingRequest"'
2018-10-23 22:25:58.159 [TRACE] [ertaintv.internal.EntertainTVNetwork] - EntertainTVNetwork: POST 'http://192.168.9.139:8081/upnp/service/X-CTC_RemotePairing/Control' - Response = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X-pairingRequestResponse xmlns:u="urn:schemas-upnp-org:service:X-CTC_RemotePairing:1">
<result>0</result>
</u:X-pairingRequestResponse>
</s:Body> </s:Envelope>'
2018-10-23 22:25:58.161 [DEBUG] [ertaintv.internal.EntertainTVControl] - EntertainTV: Pairing initiated.
2018-10-23 22:25:58.162 [TRACE] [tv.internal.EntertainTVNotifyServlet] - EntertainTVServlet: Reqeust from 192.168.9.139:43656/entertaintv/notify (192.168.9.139, HTTP/1.1)
2018-10-23 22:25:58.168 [TRACE] [tv.internal.EntertainTVNotifyServlet] - EntertainTV.Notify: Pairing code '8EAD18BC' received for deviceID '26A5F0FD7A02C93E07CFC428C499D182'
2018-10-23 22:25:58.172 [DEBUG] [ertaintv.internal.EntertainTVControl] - EntertainTV: Pairing code refreshed ('8EAD18BC')

I have more time tomorrow evening, then I test it extensively.

Also volume up / down works right now.

Tobias

Possibly. We could also do a TeamViewer session on Thursday evening and test together. If it suits you.
Then have online:

  • MR401
  • MR400
  • MR201

(Is it really not possible to send PMs in this community?)

It is possible. Click on the user name and popup occurs where you can select “message” to send a private message.

ok, I transformed @Mat_Ias’s bash script to generate the userID into java and did a first successful run. As a result I received the correct hashed user id.

@Sebastian_Kastner / @Mat_Ias could you find our more information on the problem running the script with Sebastian’s credentials? Would be good to understand the reason so I could adapt that to the binding.


Question: I want to enable the user to enter his credentials as a clear text in the binding properties. This will be used by the binding to run the authentication and get the userID. However, I think it’s also a good idea to remove the credentials afterwards. There is no need to have them if the binding has the userID.

For this I suggest the following:
You could enter your credentials in the userID field in the format: @t-online.de;
When the thing initializes this setting will be used to generate the userID.
If the userID was received successful it will be shown in the log (not the credentials!) and saved as a thing property.
The user has now the option to use [Show Properties] and copy&paste the userID into the thing config (overwriting the credentials).
On the next start the binding won’t do a re-authentication, because it has already the userID - faster and more secure, because the credentials get removed from the configuration.

What do you think?

Why ???
Have a look at the digitalSTROM binding (ESH). It uses credentials to log into the server, receives an ApplicationToken which is stored as a config property automatically and will be used instead of credentials. There is no user interaction needed.

Just some part of the needed code:

            boolean configChanged = false;
            Configuration configuration = bridge.getConfig();
            if (connMan.getApplicationToken() != null) {
                configuration.remove(USER_NAME);
                configuration.remove(PASSWORD);
                logger.debug("Application-Token is: {}", connMan.getApplicationToken());
                configuration.put(APPLICATION_TOKEN, connMan.getApplicationToken());
                configChanged = true;
            }

hmm, sounds smart. I’ll try that.

1 Like

implementation is done, I need to add some more error handling and then update the release

1 Like

ok, here is the first build with integrated OAuth.
https://github.com/markus7017/org.openhab.binding.entertaintv/blob/beta1/target/org.openhab.binding.entertaintv-2.4.0-SNAPSHOT.jar

You need to remove and re-discover the thing to get the new config options:

  • accountName is your T-Online user id (xxxx@t-online.de)
  • accountPassword is your matching password (case sensitive)

If the userID is empty AND account credentials are configured the binding uses the Telekom OAuth service to query the userID. Once this data is received the binding saves it to the configuration data and automatically removes the account credentials.

You could verify that be re-editing the thing config. In this case the credentials are empty and the userID is filled (see [SHOW MORE]).

The credentials will not be removed if the authentication fails.

Enable TRACE mode to get information on the OAuth flow.

This build also include the periodic re-subscribe to the event channel and re-newing the pairing code.

Thanks @Mat_Ias for doing the basic research and contributing the script.:+1:

Would be great if all of you do a test so we cover various environments. @ibot1989 I’m also interested in the results for MR400 and MR201 - I expect some additional work here.

@markus7017
The MR201 create no Thing in the inbox:

2018-10-27 23:46:14.668 [TRACE] [very.EntertainTVDiscoveryParticipant] - EntertainTV: Device discovered: Huawei Technologies Co.,Ltd - MR401B
2018-10-27 23:46:14.673 [DEBUG] [very.EntertainTVDiscoveryParticipant] - EntertainTV: Discovered an EntertainTV Receiver 'Telekom Wohnzimmer', UDN: 'c1026e4c-e7fd-5393-a2f3-AC6FBB5C6A01', Model MR401B.R01A3
2018-10-27 23:46:14.678 [DEBUG] [very.EntertainTVDiscoveryParticipant] - EntertainTV: Create Thing for device 'Telekom Wohnzimmer' with UDN 'c1026e4c-e7fd-5393-a2f3-AC6FBB5C6A01, Model'MR401B'
2018-10-27 23:46:14.683 [DEBUG] [v.internal.EntertainTVHandlerFactory] - EntertainTV: Refresh Device Status for UDN 'C1026E4C-E7FD-5393-A2F3-AC6FBB5C6A01'
2018-10-27 23:46:14.706 [DEBUG] [.internal.handler.EntertainTVHandler] - EntertainTV: Refesh device status for 'C1026E4C-E7FD-5393-A2F3-AC6FBB5C6A01' (UDN='{}'
2018-10-27 23:46:14.732 [TRACE] [very.EntertainTVDiscoveryParticipant] - EntertainTV: Device discovered: Huawei Technologies Co.,Ltd - MR201

The network had MR401B and MR201 online during the scan.

Trace from the MR400 is coming tomorrow.

I have the feeling, when I put MR400 and MR401B as a thing, that the control of the MR401B does not work anymore. More about this tomorrow.

Hi Tobias, I added the MR201 to the discovery for the latest build.

I also noticed that clearing the credentials causes a problem with thing not being initialized on a restart. I now replace the credentials with “***” (just a dummy text), which will also be used to check for empty credentials. The saved userID will be used for further pairings.

fyi: The binding survived the upgrade to MagentaTV. This major update seems to be compatible to what we need.

Question: The name “EntertainTV Binding” is now mis-leading, because Telekom renamed their product.
What do you think about the binding name?

Does anyone has the capability to develop a nice HABpanel widget? The binding supplies the remote control function as well as information about current program etc.

Yes, should be refactored to MagentaTV Binding.

so far ao good

2 Likes

I think “TelekomTV Binding” is a good name.

A new build has been uploaded - [beta1] (make sure to select the beta1 branch).
The README has been updated

  • fixes a endless loop in the background re-subscribe / re-pairing thread if the receiver does not reply with a valid result. If connection gets lost the binding tries to re-connect. However, rocvery scenarios are not fully tested yet.
  • MR201 added to discovery. Not yet tested @ibot1989 :upside_down_face:
  • Marked accountName and accountPassword as mandatory config parameters. This makes sure that you have to enter credentials before the thing gets finally added. Once the OAuth authentication is completed and the userID has been queried successful the binding will replace the credentials with ‘***’. This allows editing the config afterwards. If you prefer to manually discover the userID (Wireshark / tcpdump, see above) set the both field to *** and enter the userID under the advanced options.
  • code cleanup, more error checking

Based on your feedback/test results I will close Beta 1. Next step will be to rename / refactor the binding to telekomtv - it doesn’t makes sense to keep the entertaintv name, because the Telekom TV services has been rebranded to MagentaTV. I’ll create a new thread when beta 2 is ready to test.

Is anyone able to contribute a sitemap for the OH App or a nice HABpanel?

Hi,
searching for an Entertain Binding I found yours and wanted to give it a try.
Unfortunately it does not work, it´s not loading at all.

I used the beta1 linked in the post above an copied it into the /usr/share/openhab2/addons folder, like I did with other bindings that are loading. I also restarted openHab w/o success.

 bundle:list

on the karaf console doesn’t show it and the log files has no entries for it either.

What do I have to do to get it loaded?
Thanks for your help, Udo

Raspbian GNU/Linux 9 (stretch)
Kernel = Linux 4.14.71-v7+
Platform = Raspberry Pi 3 Model B Rev 1.2
OepnHAB = openhab 2.3.0-1

Hi @UdoJR - welcome to the club :slight_smile:

I suppose your installation is missing the upnp support (unless you have other bindings installed that use UPnP like the HUE binding).

open OH console and run bundle:list, you should see sthg like

229 │ Active   │  80 │ 0.10.0.oh230           │ Eclipse SmartHome Configuration UPnP Discovery
230 │ Active   │  80 │ 0.10.0.oh230           │ Eclipse SmartHome UPnP Transport Bundle

if not install upnp feature:

feature:install esh-io-transport-upnp

Which media receiver are you using?

I’ll add that to the README - please read before installing the binding.

Hi @markus7017,

thanks for your help. :slight_smile:

I use the Hue Binding, therefor I have installed the following bundles:

173 │ Active   │  80 │ 2.3.0                  │ JUPnP Library
196 │ Active   │  80 │ 0.10.0.oh230           │ Eclipse SmartHome Configuration UPnP Discovery
198 │ Active   │  80 │ 0.10.0.oh230           │ Eclipse SmartHome UPnP Transport Bundle

Other ideas? In the same folder I have bosesoundtouch-0.10.0, amazonechocontrol_2.4.2 and the network-2.4.0 Bindings, all three are loading w/o problems. But I think the entertaintv-2.4.0 binding is not touched at all?

I have very old ones, the first MR300 and a MR102B

Ok, I read it before very quickly, will read it again later :wink: