MagentaTV Binding for Deutsche Telekom MR 4xx

I’ll have a look to that at the weekend and send you a PM

Hey @markus7017, this binding looks like some awesome work - is there any specific reason why you didn’t create a PR for it yet so that it could become a part of the official distro?

3 Likes

@Kai he he - time :slight_smile:

I need to finalize a change using channel groups, which gives it a way better structure to understand.

And finally: I hadn’t checked how to create a PR for the main project. My understanding

  • fork the OH2 addons proect
  • add new binding
  • create PR
    Simple problem: I have already forked a binding, which is based on the OH2 addons fork, so I can’t have another repo in my GitHub account with the same name.

If I’m right this is a general issue from a developer’s perspective. How to bring multiple bindings into a single source tree if they are all using the OH2 addons fork beside adding my own (Telekom TV, Apple-TV, Rachio Sprinkler, Whatsapp - but this is depreciated, because WhatsApp shutdown the API)

My personal solution is to create a repo per binding, but then I need to bring them together to create a PR. Could you give some advise or point me to some documentation?

Ok, but this does not need to prevent you from creating a PR (being marked as WIP (=“Work in Progress”)).

I’d actually have one remark wrt the naming (which is always the hardest part, I know, and you have already once changed it): We usually really use the product names, so here (after EntertainTV has been retired by DT) it would clearly be “MagentaTV”. The current name “TelekomTV” is imho not clear enough - while for Germany, “Telekom” is associated with “Deutsche Telekom”, this is probably not the association internationally. And changing the binding to “deutschetelekomtv” is a probably pretty ugly, so “magentatv” would be my clear preference here.

No, you always only need a single fork of the repo. The way it works is that you create a separate (feature) branch per binding and you create a PR for every branch for a specific binding. See also https://www.openhab.org/docs/developer/contributing/contributing.html#conventions or Feature Branches and Pull Requests : Walkthrough · GitHub.

ok, I started refacoring the bindig: OH 2.5 SNAPSHOT, new name, channel groups

Stay tuned, I’ll post and update when this build is running, so we could do a regressions test.

@dbghb I’ll also some more TRACE messages to narrow your problem.

Hi guys, I need your help. As requested by Kai I renamed the binding to MagentaTV (Entertain TV is only mentioned in the README to come up if someone is searching for it).

I refactored the code:

  • New name is MagentaTV (org.openhab.binding.magentatv)
  • implemented channel groups to improve view in PaperUI->Control
  • fixed a bug where a pairing code was ignored, because the device lookup failed (Pairing code for unregistered device)
  • periodic re-pairing is disabled. For my installation that works fine and avoids the annoying “Connected to openHAB” messages on the TV screen
  • README updated

A initial PR has been created to make it into the official distro for OH release 2.5. It’s still WIP, work in progress. I want to do some testing before submitting the final PR (shouldn’t be to much work) - thanks @Kai for the heads-up.

Please report testing results here:

  • OH version, operating system
  • Type and number of media receiver(s) (3xx / 4xx)
    I would like to include supported combinations in the README.
    My setup: macOS with 2.5 dev environment and RPi 3 with openHAB 2.4 release. I’m also interested on Synology results.

Does someone has a sitemap to contribute to the README. I have non, because I use HABpanel UI.

You could find the new jar here: https://github.com/markus7017/openhab2-addons/blob/add_linting/addons/binding/org.openhab.binding.magentatv/target/org.openhab.binding.magentatv-2.5.0-SNAPSHOT.jar

Installation:

  • Remove all TelekomTV things (you need to re-discover, maybe make a copy of jsondb)
  • delete org.openhab.binding.telekomtv*.jar from the addons folder
  • copy org.openhab.binding.magentatv-2.5.0-SNAPSHOT.jar to the addons folder
  • change to PaperUI->Inbox
  • run discovery, add thing, link channels

Don’t be afraid to install the 2.5.0-SNAPSHOT build on OH 2.4, it will run (I’m still on 2.4). I’m not sure about 2.3 - maybe the channel groups break backward compatibility to 2.3.

Thanks for supporting the final steps.

1 Like

Hi Markus,

the new release (2.5.0-SNAPSHOT) seems to work perfectly.
The former release made problems in connection with my Synology.
Now everything seems to work fine.

Here my setups :

  1. Synology (my regular OH server)
    Openhab Version 2.4.0.001
    Synology DSM 6.2.1
    Media Receiver MR401B

  2. MacOS (used for testing)
    Openhab Version 2.4.0
    MacOS 10.14.1
    Media Receiver MR401B

thx for the feedback, so I could proceed to make it part of the 2.5 release.
My setup is running on RPIs with Openhabian and openHAB 2.4 release, dev environment is macOS.

I did another checkin to fix a timing issue on initialization. This could result in the situation that the thing was initialized faster than the NotifyServlet was started so the pairing request was send, but the code not received, because the servlet was not there. Now the initialization waits until the servlet is started.

Please let me know if there are any other issues or you are interested in a specific feature.

Important note: Even the filename includes “2.5-SNAPSHOT” the binding will work on 2.4. I’m not sure about 2.3, because the channel group feature might break backward compatibility.

Please don’t forget to remove existing things from PaperUI and deleting the telekomtv bindingbefore installing the new magentatv binding. After that you could re-link the channels to the existing items, so you don’t need to change rules etc.

Hello @markus7017,

i have try the new version of the Binding and have found a typing error in the channel overview in the processing of the thing. Under Play Status - STttus information on media play.

good catch :slight_smile:
thx, fixed

Hello,

i have the problem, the Thing is online und informations are updated on channel switch.

But after ~10 minutes, no more information update on channel switching.
I can switching channels via binding, but no information to, the log file:

2019-03-25 20:29:24.914 [ome.event.ItemCommandEvent] - Item 'TelekomWohnzimmer_Control_ChannelUp' received command ON

==> /var/log/openhab2/openhab.log <==
2019-03-25 20:29:24.926 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Channel command for device Telekom Wohnzimmer: ON for channel control#channelUp
2019-03-25 20:29:24.932 [DEBUG] [.magentatv.internal.MagentaTVControl] - MagentaTV.Control: Send Key 'CHUP' (keyCode='0x0101') to device 'Telekom Wohnzimmer' (1F8C606FF3953FE4E2AFCE57EDBD70EA)
2019-03-25 20:29:24.938 [DEBUG] [.magentatv.internal.MagentaTVControl] - MagentaTV.Control: sendKey keyCode='0x0101' to 'Telekom Wohnzimmer' (1F8C606FF3953FE4E2AFCE57EDBD70EA, 192.168.9.139:8081)

==> /var/log/openhab2/events.log <==
2019-03-25 20:29:24.940 [vent.ItemStateChangedEvent] - TelekomWohnzimmer_Control_ChannelUp changed from OFF to ON

==> /var/log/openhab2/openhab.log <==
2019-03-25 20:29:24.942 [TRACE] [.magentatv.internal.MagentaTVControl] - MagentaTV.Control: sendKey terminalid='1F8C606FF3953FE4E2AFCE57EDBD70EA', pairingCode='8EAD18BC', verificationCode='E740DB4495E370DD129E1C522A700179', userId=9315609461EBA31EB238EAEA26860F99'
2019-03-25 20:29:24.945 [TRACE] [ntatv.internal.network.MagentaTVHttp] - MagentaTV.Http: POST 'http://192.168.9.139:8081/upnp/service/X-CTC_RemoteControl/Control' - SoapAction='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X_CTC_RemoteKey xmlns:u="urn:schemas-upnp-org:service:X-CTC_RemoteControl:1"><InstanceID>0</InstanceID><KeyCode>keyCode=0x0101^1F8C606FF3953FE4E2AFCE57EDBD70EA:E740DB4495E370DD129E1C522A700179^userID:9315609461EBA31EB238EAEA26860F99</KeyCode></u:X_CTC_RemoteKey></s:Body></s:Envelope>', Data = '"urn:schemas-upnp-org:service:X-CTC_RemoteControl:1#X_CTC_RemoteKey"'
2019-03-25 20:29:24.964 [TRACE] [ntatv.internal.network.MagentaTVHttp] - MagentaTV.Http: POST 'http://192.168.9.139:8081/upnp/service/X-CTC_RemoteControl/Control' - Response = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
<u:X_CTC_RemoteKeyResponse xmlns:u="urn:schemas-upnp-org:service:X-CTC_RemoteControl:1"></u:X_CTC_RemoteKeyResponse>
</s:Body> </s:Envelope>'

==> /var/log/openhab2/events.log <==
2019-03-25 20:29:24.978 [vent.ItemStateChangedEvent] - TelekomWohnzimmer_Control_ChannelUp changed from ON to OFF

And the last log informations bevor no more informations are comming on switching:

==> /var/log/openhab2/openhab.log <==
2019-03-25 20:39:25.920 [TRACE] [ernal.network.MagentaTVNotifyServlet] - MagentaTV.NotifyServlet: Reqeust from 192.168.9.139:57049/magentatv/notify (192.168.9.139, HTTP/1.1)
2019-03-25 20:39:25.924 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Received STB Event from MAC AC6FBB5C6A01
2019-03-25 20:39:25.928 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Lookup device, uniqueId=AC6FBB5C6A01
2019-03-25 20:39:25.932 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Devies[0]: deviceId=1F8C606FF3953FE4E2AFCE57EDBD70EA, UDN=C1026E4C-E7FD-5393-A2F3-AC6FBB5C6A01, ipAddress=192.168.9.139, macAddress=AC6FBB5C6A01
2019-03-25 20:39:25.937 [TRACE] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Process STB event for device Telekom Wohnzimmer, json='{"new_play_mode":20,"playBackState":1,"mediaType":1,"mediaCode":"3679"}'
2019-03-25 20:39:25.942 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: STB event playContent: playMode=buffering, duration=-1, playPosition=-1

==> /var/log/openhab2/events.log <==
2019-03-25 20:39:25.956 [vent.ItemStateChangedEvent] - TelekomWohnzimmer_Status_PlayMode changed from playing (MC) to buffering

==> /var/log/openhab2/openhab.log <==
2019-03-25 20:39:26.129 [TRACE] [ernal.network.MagentaTVNotifyServlet] - MagentaTV.NotifyServlet: Reqeust from 192.168.9.139:57050/magentatv/notify (192.168.9.139, HTTP/1.1)
2019-03-25 20:39:26.132 [TRACE] [ernal.network.MagentaTVNotifyServlet] - MagentaTV.NotifyServlet: Reqeust from 192.168.9.139:57051/magentatv/notify (192.168.9.139, HTTP/1.1)
2019-03-25 20:39:26.132 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Received STB Event from MAC AC6FBB5C6A01
2019-03-25 20:39:26.135 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Received STB Event from MAC AC6FBB5C6A01
2019-03-25 20:39:26.137 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Lookup device, uniqueId=AC6FBB5C6A01
2019-03-25 20:39:26.138 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Lookup device, uniqueId=AC6FBB5C6A01
2019-03-25 20:39:26.141 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Devies[0]: deviceId=1F8C606FF3953FE4E2AFCE57EDBD70EA, UDN=C1026E4C-E7FD-5393-A2F3-AC6FBB5C6A01, ipAddress=192.168.9.139, macAddress=AC6FBB5C6A01
2019-03-25 20:39:26.144 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Devies[0]: deviceId=1F8C606FF3953FE4E2AFCE57EDBD70EA, UDN=C1026E4C-E7FD-5393-A2F3-AC6FBB5C6A01, ipAddress=192.168.9.139, macAddress=AC6FBB5C6A01
2019-03-25 20:39:26.144 [TRACE] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Process STB event for device Telekom Wohnzimmer, json='{"type":"EVENT_EIT_CHANGE","instance_id":26,"channel_code":"150","channel_num":"3","mediaId":"1748","program_info":[{},{}]}'
2019-03-25 20:39:26.148 [TRACE] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Process STB event for device Telekom Wohnzimmer, json='{"new_play_mode":20,"playBackState":1,"mediaType":1,"mediaCode":"1748","duration":0,"playPostion":0}'
2019-03-25 20:39:26.150 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: EVENT_EIT_CHANGE for channel 3/150
2019-03-25 20:39:26.156 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: STB event playContent: playMode=buffering, duration=0, playPosition=0
2019-03-25 20:39:26.162 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: EVENT_EIT_CHANGE: empty event data = '{"type":"EVENT_EIT_CHANGE","instance_id":26,"channel_code":"150","channel_num":"3","mediaId":"1748","program_info":[{},{}]}'

==> /var/log/openhab2/events.log <==
2019-03-25 20:39:26.164 [vent.ItemStateChangedEvent] - TelekomWohnzimmer_Status_Channel changed from 4 to 3

==> /var/log/openhab2/openhab.log <==
2019-03-25 20:39:26.165 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: EVENT_EIT_CHANGE: empty event data = '{"type":"EVENT_EIT_CHANGE","instance_id":26,"channel_code":"150","channel_num":"3","mediaId":"1748","program_info":[{},{}]}'
2019-03-25 20:39:26.179 [TRACE] [ernal.network.MagentaTVNotifyServlet] - MagentaTV.NotifyServlet: Reqeust from 192.168.9.139:57052/magentatv/notify (192.168.9.139, HTTP/1.1)
2019-03-25 20:39:26.188 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Received STB Event from MAC AC6FBB5C6A01
2019-03-25 20:39:26.192 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Lookup device, uniqueId=AC6FBB5C6A01
2019-03-25 20:39:26.197 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Devies[0]: deviceId=1F8C606FF3953FE4E2AFCE57EDBD70EA, UDN=C1026E4C-E7FD-5393-A2F3-AC6FBB5C6A01, ipAddress=192.168.9.139, macAddress=AC6FBB5C6A01
2019-03-25 20:39:26.201 [TRACE] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Process STB event for device Telekom Wohnzimmer, json='{"type":"EVENT_EIT_CHANGE","instance_id":26,"channel_code":"150","channel_num":"3","mediaId":"1748","program_info":[{"event_id":"34744","start_time":"2019/03/25 19:15:00","duration":"00:45:00","running_status":4,"free_CA_mode":false,"short_event":[{"language_code":"DEU","event_name":"Markt","text_char":"Moderation: Jo Hiller"}]},{"event_id":"34745","start_time":"2019/03/25 20:00:00","duration":"00:45:00","running_status":1,"free_CA_mode":false,"short_event":[{"language_code":"DEU","event_name":"Die Bewegungs-Docs","text_char":"Film von Lukas Rieckmann"}]}]}'
2019-03-25 20:39:26.207 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: EVENT_EIT_CHANGE for channel 3/150
2019-03-25 20:39:26.220 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Info for channel 3 / 150 - running 'Markt'.'Moderation: Jo Hiller', start time=2019/03/25 20:15, duration=00:45:00

==> /var/log/openhab2/events.log <==
2019-03-25 20:39:26.234 [vent.ItemStateChangedEvent] - TelekomWohnzimmer_Program_Program changed from Tamer Bakiner - Der Wahrheitsjäger to Markt

==> /var/log/openhab2/openhab.log <==
2019-03-25 20:39:26.252 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Info for channel 3 / 150 - stopped 'Die Bewegungs-Docs'.'Film von Lukas Rieckmann', start time=2019/03/25 21:00, duration=00:45:00

==> /var/log/openhab2/events.log <==
2019-03-25 20:39:26.268 [vent.ItemStateChangedEvent] - TelekomWohnzimmer_Program_Description changed from (1/1) to Moderation: Jo Hiller
2019-03-25 20:39:26.280 [vent.ItemStateChangedEvent] - TelekomWohnzimmer_Program_Duration changed from 02:00:00 to 00:45:00

==> /var/log/openhab2/openhab.log <==
2019-03-25 20:39:26.406 [TRACE] [ernal.network.MagentaTVNotifyServlet] - MagentaTV.NotifyServlet: Reqeust from 192.168.9.139:57053/magentatv/notify (192.168.9.139, HTTP/1.1)
2019-03-25 20:39:26.410 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Received STB Event from MAC AC6FBB5C6A01
2019-03-25 20:39:26.413 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Lookup device, uniqueId=AC6FBB5C6A01
2019-03-25 20:39:26.416 [TRACE] [atv.internal.MagentaTVHandlerFactory] - MagentaTV.Factory: Devies[0]: deviceId=1F8C606FF3953FE4E2AFCE57EDBD70EA, UDN=C1026E4C-E7FD-5393-A2F3-AC6FBB5C6A01, ipAddress=192.168.9.139, macAddress=AC6FBB5C6A01
2019-03-25 20:39:26.419 [TRACE] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Process STB event for device Telekom Wohnzimmer, json='{"new_play_mode":4,"playBackState":1,"mediaType":1,"mediaCode":"1748","duration":0,"playPostion":0}'
2019-03-25 20:39:26.424 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: STB event playContent: playMode=playing (MC), duration=0, playPosition=0

==> /var/log/openhab2/events.log <==
2019-03-25 20:39:26.445 [vent.ItemStateChangedEvent] - TelekomWohnzimmer_Status_PlayMode changed from buffering to playing (MC)

A little additional information to the problem:

When no more informations comming to openHAB, in the logs comes after a time:

==> /var/log/openhab2/openhab.log <==
2019-03-25 21:03:15.456 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Check receiver status, current state  ONLINE/NONE
2019-03-25 21:03:15.462 [DEBUG] [.magentatv.internal.MagentaTVHandler] - MagentaTV.Handler: Renew MR event subscription for device 'Telekom Wohnzimmer'

Is it correct that there the current status is displayed as “current state ONLINE / NONE”, or what does that mean?

yes, this is correct - there is a Thing status and sub status; e.g. for OFFLINE sub status could be COMMUNICATION_ERROR

what changed in your setup or was the problem already existing for a while?

Hey Markus,

the problem comes with testing the new jar Version of the Binding.

which was the old one, wich is the new one?
did you switched from telekomtv to magentatv?

I‘m still working on the PR to make the magentatv binding ready for the 2.5 release. The process requires sanatizing and some refactoring, not a big issue, but needs time.

If your are happy with the telekomtv version please continue until Inhave the 2.5 ready for more testing.

The new one is this:
233 │ Active │ 80 │ 2.5.0.201903072220 │ MagentaTV Binding

The old one was this:
EntertainTV Binding 2.4.0.201811150104

I want to support you in further testing for PR, so I used the new version.

appreciate :slight_smile: There is one significant difference in magentatv: I disabled the periodic repairing, because on every pairing you get the „Connected to openHAB“ message on the TV screen - not sure if that is for the MR401 only. I tried to disablr it and in my setup it still works.

ok, it took a while, but I made progress in refactoring for the 2.5 distro and also found some bugs.
I like to share this version with you
org.openhab.binding.magentatv-2.5.0-SNAPSHOT.jar.pdf (72.3 KB)
(it’s a 2.5 build, but also works on 2.4; rename to .jar after download)

Beside refactoring of exception and log handling (following the requests to merge with the official distro) I was able to fix some bugs:
Changes:

  • change: periodically re-subsribe to the event channel, but do not re-pair
  • change: the new key PAIR forces a re-pairing
  • fix: “device already registered” on initialization
  • fix: reset pairing on every connect
  • refactored: network initialization is delayed to fix timing issue on startup

I’m optimistic that the 1st changes fixes the problem that program events will no longer received after a while and at the same time suppressing the “openHAB connected” screen message. In my setup it worked over night, switching the channel in the morning results in update on program information.

Please help to harden the release before submitting to review by the OH distro team.

I decided put put the PR “merge MagentaTV binding to the 2.5” on hold and closed the PR.

I created a new repo here:

which also incudes the latest build of the binding:
https://raw.github.com/markus7017/org.openhab.binding.magentatv/blob/master/target/org.openhab.binding.magentatv-2.5.0-SNAPSHOT.jar