MagentaTV Binding for Deutsche Telekom MR 4xx

It works on my MR401 and MR201, thank you :slight_smile:

good job :slight_smile:

I tried to implement some code to get the ID automatically. As i work on a iobroker Adapter for MagentaTv i implemented something in JS. I share this with you as you Java Code helped me to get the Connection ready. Maybe you can transfer it to Java.

I used peppeteer which is a headless Browser and i did the regular Login Process on the Website from Telekom and waited for the response with the UserID.

const puppeteer = require('puppeteer')
const crypto = require('crypto');
const username = 'xxxx';
const password = 'xxxx';
(async () => {
    const browser = await puppeteer.launch({args:['--no-sandbox'],executablePath: '/usr/bin/chromium'})
    const page = await browser.newPage()
    await page.goto('https://web.magentatv.de/login', { waitUntil: 'networkidle2' })
    await page.type('#username', username)
    await page.click('#pw_submit')
    await page.waitForNavigation()
    await page.type('#pw_pwd', password)
    page.on('requestfinished', async (request) => {    
        if(request.url().includes("DTAuthenticate")){
            try {
                var json = await request.response().json();
                console.log(crypto.createHash('md5').update(json.userID).digest("hex").toUpperCase()); 
                browser.close()
            } catch (error) {
                console.log(error);
            }
       }
  }); 
  await page.click('#pw_submit')
  await page.waitForNavigation()
})()

At the end i find my ID in the Log.

you can‘t call puppetier from java, but the sccessor playwright https://github.com/microsoft/playwright-java

nevertheless, embedding this to the binding requires 3rd party artifacts, not sure if that goes through a PR review

Every now and then I try to get this binding up and running in my setup but without success so far. I know that discovery won’t work as I have the receiver in a separate subnet. However I’m still not sure if that means that it just won’t work at all or if I have to do some manual configuration. Documentation says I have to manually configure the thing. I retrieved the userID as described by @h3llh0und but I don’t know if there is a known way to also retrieve the missing UDN and IP Port Parameters?

EDIT: Ok dug a little deeper and retrieved the UDN and realized that port is 8081. However I get a pairing result -2.

This is the log output:

2021-11-02 22:26:33.796 [DEBUG] [tv.internal.handler.MagentaTVControl] - : Check device ED113A2E1DB7649326459F2BD037DA74 (10.9.40.6:8081)
2021-11-02 22:26:33.812 [TRACE] [ntatv.internal.network.MagentaTVHttp] - GET http://10.9.40.6:8081/xml/dial.xml - Response=<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<UDN>uuid:dd91b48c-0645-5261-8f29-AC6FBB711C32</UDN>
<friendlyName>DMS_AC6FBB711C32</friendlyName>
<deviceType>urn:schemas-upnp-org:device:tvdevice:1</deviceType>
<manufacturer>Zenterio</manufacturer>
<modelName>MR401B_ACN</modelName>
<modelNumber>R01A5</modelNumber>
<productVersionNumber>&quot; 640 &quot;</productVersionNumber>
<productType>stb</productType>
<serialNumber></serialNumber>
<X_wakeOnLan>0</X_wakeOnLan>
<serviceList>
<service>
<serviceType>urn:dial-multiscreen-org:service:dial:1</serviceType>
<serviceId>urn:dial-multiscreen-org:service:dial</serviceId>
</service>
</serviceList>
</device>
</root>

2021-11-02 22:26:33.814 [DEBUG] [tv.internal.handler.MagentaTVControl] - : Wake-on-LAN is disabled
2021-11-02 22:26:33.814 [TRACE] [tv.internal.handler.MagentaTVControl] - : Online status verified for device 10.9.40.6:8081, UDN=UUID:DD91B48C-0645-5261-8F29-AC6FBB711C32
2021-11-02 22:26:33.814 [TRACE] [tatv.internal.MagentaTVDeviceManager] - Register new device, UDN=UUID:DD91B48C-0645-5261-8F29-AC6FBB711C32, deviceId=ED113A2E1DB7649326459F2BD037DA74, ipAddress=10.9.40.6
2021-11-02 22:26:33.814 [DEBUG] [tatv.internal.MagentaTVDeviceManager] - New device added: (UDN=UUID:DD91B48C-0645-5261-8F29-AC6FBB711C32 ,deviceId=ED113A2E1DB7649326459F2BD037DA74, ipAddress=10.9.40.6, macAddress=AC6FBB711C32), now 1 devices.
2021-11-02 22:26:33.815 [DEBUG] [tv.internal.handler.MagentaTVControl] - : Subscribe Event Channel (terminalID=ED113A2E1DB7649326459F2BD037DA74, 10.9.40.6:8081
2021-11-02 22:26:33.837 [DEBUG] [tv.internal.handler.MagentaTVControl] - : SUBSCRIBE returned SID 27d59026-747d-50f1-bdc9-365888f71334
2021-11-02 22:26:33.837 [DEBUG] [tv.internal.handler.MagentaTVControl] - : Send Pairing Request (deviceID=ED113A2E1DB7649326459F2BD037DA74, type=PAD:openHAB, userID=XXXXXXXXXXXXXXXXXXXXXXX)
2021-11-02 22:26:33.838 [TRACE] [ntatv.internal.network.MagentaTVHttp] - POST http://10.9.40.6: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>ED113A2E1DB7649326459F2BD037DA74</pairingDeviceID><friendlyName>PAD:openHAB</friendlyName><userID>XXXXXXXXXXXXXXXXXXXXXXX</userID></u:X-pairingRequest></s:Body></s:Envelope>, Data = "urn:schemas-upnp-org:service:X-CTC_RemotePairing:1#X-pairingRequest"
2021-11-02 22:26:33.860 [TRACE] [ntatv.internal.network.MagentaTVHttp] - POST http://10.9.40.6: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>-2</result>
</u:X-pairingRequestResponse>
</s:Body> </s:Envelope>
2021-11-02 22:26:33.863 [DEBUG] [tv.internal.handler.MagentaTVHandler] - Media Receiver: org.openhab.binding.magentatv.internal.MagentaTVException: Pairing failed, result=-2
2021-11-02 22:26:33.863 [DEBUG] [tv.internal.handler.MagentaTVHandler] - Media Receiver: Communication Error - org.openhab.binding.magentatv.internal.MagentaTVException: Pairing failed, result=-2, switch Thing offline

Is the Magenta TV Box tested? I have one as primary Receiver but this one isn’t discovered.
any Ideas? the second receiver is a 201 that works fine.
I use openhab 3.1.

I know only MR400, 401, 201
turn on DEBUG log and see if the MTV box is discovered as an UPnP device, but ignored due to a unknown model name/id

8081 is used by the MR400
Did you MD5ed the UID?

No I didn’t MD5 the uuid. Now that you mentioned it I tried to MD5 and hexifiy the whole string and only the uuid Part. However the syntax may still be different, I got the same results so far


Oh maybe I got you wrong: I did calculate the MD5 hash on the userId but not the UDN.

According to the description above 2 steps are required: first MD5 the UID, then change result to uppercase. For me it worked like this.

The UID is not a UUID, follow exactly the steps here: MagentaTV Binding for Deutsche Telekom MR 4xx - #688 by h3llh0und

  • get UID from browser console
  • MD5 + uppercase it
  • put the strong into the thing config

Hmm that’s exactly what I did
 but I will double check anyway to see if I made a mistake somewhere along the way. Thanks for your help!

EDIT: Ok I accidentally inserted a line break in the MD5 calculator. However now get a Timeout on the pairing request:

2021-11-05 15:59:11.505 [DEBUG] [tv.internal.handler.MagentaTVControl] - : Pairing initiated (deviceID=ED113A2E1DB7649326459F2BD037DA74).
2021-11-05 15:59:26.506 [DEBUG] [tv.internal.handler.MagentaTVHandler] - Media Receiver: Communication Error - Timeout on pairing request!, switch Thing offline

The Magenta TVBox is working now.
Adding the Thing manually, I filled in the IP Address, which is the one, I got it from my Fritz.box.
The device starts with DMS-.
The Telekom Login credentials and since i have the MR201 running I copied the userID from there.
The last Information was to get the UDN via http://:8081/xml/dial.xml
Thats it.

Some more Information: The TV Box Dial.xml:


1
0


uuid:6ea170fe-5bbd-5042-8144-AC6FBB976F4E
DMS_AC6FBB976F4E
urn:schemas-upnp-org:device:tvdevice:1
Zenterio
MRG5
R01A1
" 640 "
stb

<X_wakeOnLan>1</X_wakeOnLan>


urn:dial-multiscreen-org:service:dial:1
urn:dial-multiscreen-org:service:dial



It might help to do an autodiscovery

please insert code fences around thr xml (click on the </> button int the toolbar), orherwise it get malformed when inserting here

Hi guys,
I want to use the MagentaTV Binding for my receiver, but I have a problem receiving the User ID.
When I try to enter the email adress and password via openhab console, it’s like the keys are not responding, so I can’t enter the correct user email.
The value which is displayed in the console is not the same which is sent to the authentication.

Anybody had the same issue?

Using openhabian on a raspberry pi if this helps.

please scroll back in this thread
see MagentaTV Binding for Deutsche Telekom MR 4xx - #688 by h3llh0und

Does anyone have any clue for me what might be the problem with my timeout on pairing request problem?

This is the content of the dial.xml:

<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<UDN>uuid:XXXXXXXXXXXXXXXXXXXXXXX</UDN>
<friendlyName>DMS_AC6FBB711C32</friendlyName>
<deviceType>urn:schemas-upnp-org:device:tvdevice:1</deviceType>
<manufacturer>Zenterio</manufacturer>
<modelName>MR401B_ACN</modelName>
<modelNumber>R01A5</modelNumber>
<productVersionNumber>" 673 "</productVersionNumber>
<productType>stb</productType>
<serialNumber/>
<X_wakeOnLan>0</X_wakeOnLan>
<serviceList>
<service>
<serviceType>urn:dial-multiscreen-org:service:dial:1</serviceType>
<serviceId>urn:dial-multiscreen-org:service:dial</serviceId>
</service>
</serviceList>
</device>
</root>

And my trace log:

2021-12-29 20:26:33.137 [TRACE] [tatv.internal.MagentaTVDeviceManager] - Lookup device, uniqueId=ED113A2E1DB7649326459F2BD037DA74
2021-12-29 20:26:33.138 [TRACE] [tatv.internal.MagentaTVDeviceManager] - Devies[0]: deviceId=ED113A2E1DB7649326459F2BD037DA74, UDN=UUID:DD91B48C-0645-5261-8F29-AC6FBB711C32, ipAddress=10.9.40.6, macAddress=AC6FBB711C32
2021-12-29 20:26:33.138 [TRACE] [tatv.internal.MagentaTVDeviceManager] - Device with UDN UUID:DD91B48C-0645-5261-8F29-AC6FBB711C32 removed from table, new site=1
2021-12-29 20:26:38.167 [DEBUG] [atv.internal.MagentaTVHandlerFactory] - Create thing type magentatv:receiver
2021-12-29 20:26:43.175 [DEBUG] [tv.internal.handler.MagentaTVControl] - Media Receiver: Check device ED113A2E1DB7649326459F2BD037DA74 (10.9.40.6:8081)
2021-12-29 20:26:43.189 [TRACE] [ntatv.internal.network.MagentaTVHttp] - GET http://10.9.40.6:8081/xml/dial.xml - Response=<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<UDN>uuid:dd91b48c-0645-5261-8f29-AC6FBB711C32</UDN>
<friendlyName>DMS_AC6FBB711C32</friendlyName>
<deviceType>urn:schemas-upnp-org:device:tvdevice:1</deviceType>
<manufacturer>Zenterio</manufacturer>
<modelName>MR401B_ACN</modelName>
<modelNumber>R01A5</modelNumber>
<productVersionNumber>&quot; 673 &quot;</productVersionNumber>
<productType>stb</productType>
<serialNumber></serialNumber>
<X_wakeOnLan>0</X_wakeOnLan>
<serviceList>
<service>
<serviceType>urn:dial-multiscreen-org:service:dial:1</serviceType>
<serviceId>urn:dial-multiscreen-org:service:dial</serviceId>
</service>
</serviceList>
</device>
</root>

2021-12-29 20:26:43.189 [DEBUG] [tv.internal.handler.MagentaTVControl] - Media Receiver: Wake-on-LAN is disabled
2021-12-29 20:26:43.190 [TRACE] [tv.internal.handler.MagentaTVControl] - Media Receiver: Online status verified for device 10.9.40.6:8081, UDN=UUID:DD91B48C-0645-5261-8F29-AC6FBB711C32
2021-12-29 20:26:43.190 [TRACE] [tatv.internal.MagentaTVDeviceManager] - Register new device, UDN=UUID:DD91B48C-0645-5261-8F29-AC6FBB711C32, deviceId=ED113A2E1DB7649326459F2BD037DA74, ipAddress=10.9.40.6
2021-12-29 20:26:43.190 [DEBUG] [tatv.internal.MagentaTVDeviceManager] - New device added: (UDN=UUID:DD91B48C-0645-5261-8F29-AC6FBB711C32 ,deviceId=ED113A2E1DB7649326459F2BD037DA74, ipAddress=10.9.40.6, macAddress=AC6FBB711C32), now 1 devices.
2021-12-29 20:26:43.190 [DEBUG] [tv.internal.handler.MagentaTVControl] - DMS_AC6FBB711C32: Subscribe Event Channel (terminalID=ED113A2E1DB7649326459F2BD037DA74, 10.9.40.6:8081
2021-12-29 20:26:43.201 [DEBUG] [tv.internal.handler.MagentaTVControl] - DMS_AC6FBB711C32: SUBSCRIBE returned SID 27d59026-747d-50f1-bdc9-365888f71334
2021-12-29 20:26:43.202 [DEBUG] [tv.internal.handler.MagentaTVControl] - DMS_AC6FBB711C32: Send Pairing Request (deviceID=ED113A2E1DB7649326459F2BD037DA74, type=PAD:openHAB, userID=XXXXXXXXXXXXXXXXXXX)
2021-12-29 20:26:43.202 [TRACE] [ntatv.internal.network.MagentaTVHttp] - POST http://10.9.40.6: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>ED113A2E1DB7649326459F2BD037DA74</pairingDeviceID><friendlyName>PAD:openHAB</friendlyName><userID>XXXXXXXXXXXXXXXXXXXXXXXX</userID></u:X-pairingRequest></s:Body></s:Envelope>, Data = "urn:schemas-upnp-org:service:X-CTC_RemotePairing:1#X-pairingRequest"
2021-12-29 20:26:43.215 [TRACE] [ntatv.internal.network.MagentaTVHttp] - POST http://10.9.40.6: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>
2021-12-29 20:26:43.216 [DEBUG] [tv.internal.handler.MagentaTVControl] - DMS_AC6FBB711C32: Pairing initiated (deviceID=ED113A2E1DB7649326459F2BD037DA74).
2021-12-29 20:26:58.216 [DEBUG] [tv.internal.handler.MagentaTVHandler] - Media Receiver: Communication Error - Timeout on pairing request!, switch Thing offline

Thanks a lot retrieving “userID”.
I always failed on encoding using “Cryptii”. Lately I used Notepad++ Tools->MD5->Create for encoding. Conversion to Uppercase ist also supported in this editor. :smile: :smile: