This write up assumes you have:

Mag254 IPTV box, and know the ssh root login password (default is 930920).
HDPVR from Haupauge (1211/1212).
Working MythTV backend
Working Mythweb confuration
HDMI to Component converter. I used this one:

http://amazon.com/gp/product/B011NUG...ilpage_o01_s00

Make sure you backup your MythTV database before you start. If it goes wrong - it could be hard to untangle.

Step one: Connect and activate your IPTV box with your chosen provider. I use UKTVeverywhere.com - who supplied the box.

Connect IPTV box to HDMI/Component adapter - then the component leads to the HDPVR. You can use an SPDIF cable for audio if you’d like - but I couldn’t tell an increase in sound quality.

In mythtv-setup - create a new video source without a grabber. Add the hdpvr as a tuner (using the component video and your choice of audio settings). Assign the new video source to your tuner and use /bin/true as the channel changer script for the moment. Create a dummy channel and make sure it works and you can see your channel in MythTV. (I left this as channel 1 - as I’m in the US, so my first channel is 3-1).

Step 1. Find your EPG listings. I used tv_grab_uk_rt and edited my channel list to reflect the channels I had available on my IPTV service. Making sure unavailable channels were not added to the xml file.

ie.
Code:
channel!bbc1.bbc.co.uk
channel=hd.bbc1.bbc.co.uk
channel=yorkshire.bbc1.bbc.co.uk
Says use hd.bbc1 and yorkshire.bbc1 but not generic bbc1.

I used mythweb to determine which video source number my videosource above created. (In my case 4). I then threw the listings into the mythdatabase for later editing:
Code:
MYTHCONFDIR=/home/vdr2/.mythtv /usr/local/bin/mythfilldatabase --refresh all --sourceid 4 --file --xmlfile tv_grab_uk_rt.xml
The MYTHCONFDIR line, tells mythfilldatabase where to find the mysql login information. Sourceid 4 is the video source I created above.

After this has run, you should find all your channels in MythTV, but probably all as channel #0. Go to mythweb, login to your interface and go to channel setup. (Settings, TV, Channel Info).

You can see all your channels. If you have many, you can sort by sourceid. Find all your new channels, you should see all the xmltv channel codes and the channels names should have populated. You need to set the channel number you desire (I started mine as 1001 - then corresponded the last part with the IPTV channel number - these started at 1 in my case). At the same time, add the IPTV box cable channel number into the freqid box. When you’re done, click submit.

Now the epg should be correct, in your correct timezone and should work for every channel, but will not yet change the IPTV box channel.

Step Two: get Myth to talk to your IPTV Box.

There is a Mag250 Android app which uses wifi to control the IPTV box. However, the option to turn on the Box side of this is not available with the firmware I used - I ended up using ssh.

To get this working automatically, you have to setup passwordless ssh. This means creating a keypair. I won’t go into how to do that here, but here is a fairly normal guide to explain how to do it. https://www.digitalocean.com/communi...up-ssh-keys--2

Once passwordless ssh is setup, I created the following scripts:

uktvbox.sh

Code:
#!/bin/bash

# edit the following two lines to reflect your setup.  Put your private key file path in sshkeyfile.
# Make sure its permissions are strict.

[email protected]
sshkeyfile=$HOME/.ssh/uktvkey.pem
request="$1"

case $request in
up)
        commandline="/usr/share/qt-4.6.0/sendqtevent -kqt 0x01000013 -ks 0x26"
        ;;
ok)
        commandline="/usr/share/qt-4.6.0/sendqtevent -kqt 0x01000005 -ks 0xd"
        ;;
exit)
        commandline="/usr/share/qt-4.6.0/sendqtevent -kqt 0x01000000 -ks 0x1b"
        ;;
menu)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x0100003a -ks 0x7a"
        ;;
down)
        commandline="/usr/share/qt-4.6.0/sendqtevent -kqt 0x01000015 -ks 0x28"
        ;;
up)
        commandline="/usr/share/qt-4.6.0/sendqtevent -kqt 0x01000013 -ks 0x26"
        ;;
left)
        commandline="/usr/share/qt-4.6.0/sendqtevent -kqt 0x01000012 -ks 0x25"
        ;;
right)
        commandline="/usr/share/qt-4.6.0/sendqtevent -kqt 0x01000014 -ks 0x27"
        ;;
red)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x01000030 -ks 0x70"
        ;;
green)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x01000031 -ks 0x71"
        ;;
yellow)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x01000032 -ks 0x72"
        ;;
blue)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x01000033 -ks 0x73"
        ;;
frame)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x01000035 -ks 0x75"
        ;;
tv)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x01000039 -ks 0x7a"
        ;;

1)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x31"
        ;;
2)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x32"
        ;;
3)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x33"
        ;;
4)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x34"
        ;;
5)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x35"
        ;;
6)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x36"
        ;;
7)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x37"
        ;;
8)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x38"
        ;;
9)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x39"
        ;;
0)
        commandline="/usr/share/qt-4.6.0/sendqtevent -c -kqt 0x30"
        ;;
*)
        echo Incorrect commandline
        exit 1
        ;;
esac

/usr/bin/ssh -i $sshkeyfile -t $boxip $commandline
and

change-uk-channel.sh

Code:
#!/bin/bash
# I throw all the response into /tmp/channelchange.log to debug. This could be /dev/null

echo "`date` change channel to $1" >>/tmp/channelchange.log
/usr/local/bin/uktvbox.sh menu >>/tmp/channelchange.log
sleep 1
/usr/local/bin/uktvbox.sh tv >>/tmp/channelchange.log
sleep 3
for digit in $(echo $1 | sed -e 's/./& /g'); do
/usr/local/bin/uktvbox.sh $digit >>/tmp/channelchange.log
done
echo changed >>/tmp/channelchange.log
exit 0

Make sure these are executable and that they work. You should be able to change channels by typing /usr/local/bin/change-uk-channel.sh 141

Once working, go back to mythtv-setup and change the channel change script to /usr/local/bin/change-uk-channel.sh

Myth will pass the freqid as a command line option.

At this point, it should be working.

I also added a recording finished System Event
https://www.mythtv.org/wiki/MythTV_System_Events

Of /usr/local/bin/checkstb.sh %CARDID%

Code:
#!/bin/bash
echo cardid = $1 >/tmp/checkstb.log
if [[ $1 = "4" ]]; then

        MYTHWEBURL=http://mythtv:[email protected]/mythweb/status

        wget -O - --quiet $MYTHWEBURL | grep HDPVR | \
        while read line; do
                if `echo $line | grep --quiet 'and is not recording'`; then
                        echo “Stop streaming on UKTV Box" >>/tmp/checkstb.log
                                /usr/local/bin/uktvbox.sh menu
                else
                        echo "UKTV is busy" >>/tmp/checkstb.log
                fi
        done
fi

In my case, the HDPVR was my fourth tuner. This turns off the IPTV stream to limit bandwidth.

Feel free to come up with better ideas, or even just questions.