HTTP pass.telekom.de

Hello Community,

I wonder if anyone got a binding to parse the personal monthly used online Traffic from pass.telekom.de. It seems that theres a header check. How do I have to add the User-Agent Header corectly to a HTTP binding, if this contains spaces? Url-Encoded?
Or does anyone know if theres a API from Telekom?

Thx,
Thomas

Hi Thomas,
IMHO the pass.telekom.de Website is only available of you’re connected to the mobile network. So if you’re at home and connected to your WIFI it won’t work. And it won’t work either if you’re using any other device (PC, tablet which are only connected on your Home LAN). So using only the HTTP binding will only serve a rather small use case.

Perhaps it’s an option to use an API like this:
https://capi.t-mobile.nl/documentation/

Regards,
Michael

Hello Mitch,

thanks for your reply. I forgot to say I am using mobile LTE as Internet Connection. So all my LAN and WLAN devices shows up pass.telekom.de fine. But these are normal Browsers.
I guess they parse the User Agent Header. But how do I fake this with HTTP Binding?

Hi,
I’ve tried it months ago with http-binding.
Problem: pass.telekom.de replys with data only, when a javascript-enabled browser is detected.

With plain http-request you will get an error page only

Cheers
Chrimo

Hi,
I solved it. For those who are impressed, here is my way:

  • first of all, pass.telekom.de only needs an actual User-Agent. Because OpenHab has no easy internal way to fake the User-Agent, I decided to install php-cli and run it as service:
    php -S 0.0.0.0:80 -t /home/pi/
    Without permission modifications Java seems not able to access 127.0.0.1 binding, so I bind it at 0.0.0.0.

  • Then put this in php.ini:
    user_agent="Mozilla/5.0 (iPad; CPU OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B410 Safari/600.1.4"*

  • Now I could access any PHP Scripts within /home/pi via HTTP-Binding. I created a /home/pi/bin/lte.php with this content:
    <?php require_once('simple_html_dom.php'); $html=file_get_html('http://pass.telekom.de/home?lang=en'); foreach ($html->find('div[@class=indicator]') as $e) echo array_shift(preg_replace('/.*:([0-9]+)%.*/','percent:$1:'.PHP_EOL,[$e->attr['style']])); foreach ($html->find('div[@class=barTextBelow] span') as $e) echo array_shift(preg_replace('/([0-9\.]+).*GB.*/','absolute:$1:'.PHP_EOL,[$e->text()])); foreach ($html->find('div[@class=barTextBelow]') as $e) echo array_shift(preg_replace('/.*of ([0-9\.]+).*GB.*/','maximum:$1:'.PHP_EOL,[$e->text()])); foreach ($html->find('td[@class="infoValue remainingTime"]') as $e) echo 'remaindays:'.DateInterval::createFromDateString($e->text())->format('%dd%hh').':'.PHP_EOL; ?>

  • Add this lines to openhab.cfg for caching:
    http:ltevolume.url=http://localhost/bin/lte.php http:ltevolume.updateInterval=600000

  • This is my lte.items file:
    Number ltepercent "LTE Volumen [%.1f \%]" (gLogic) { http="<[ltevolume:60000:REGEX(.*?percent:(.*?):.*)]" } Number lteabsolute "LTE Verbrauch [%.1f GB]" (gLogic) { http="<[ltevolume:60000:REGEX(.*?absolute:(.*?):.*)]" } Number ltemaximum "LTE Maximum [%.1f GB]" (gLogic) { http="<[ltevolume:60000:REGEX(.*?maximum:(.*?):.*)]" } String lteremaindays "LTE Ende in [%s]" (gLogic) { http="<[ltevolume:60000:REGEX(.*?remaindays:(.*):.*)]" }

Hope this helps someone,
Cheers

3 Likes

Great example,

If this would work via exec binding (OpenHAB runs on another machine without HTTP access, only SSH)
Therefore I can’t use the http binding for it.

This works for VF Customers: http://debianforum.de/forum/viewtopic.php?f=29&p=990319