{"id":991,"date":"2009-10-21T21:51:53","date_gmt":"2009-10-21T21:51:53","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=991"},"modified":"2009-10-21T21:51:53","modified_gmt":"2009-10-21T21:51:53","slug":"tracking-my-location-on-tv","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=991","title":{"rendered":"Tracking my location on TV"},"content":{"rendered":"<p><a href=\"http:\/\/www.flickr.com\/photos\/dalelane\/4032511625\/\" title=\"Location tracking on TV by dalelane, on Flickr\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/farm3.static.flickr.com\/2801\/4032511625_2e571b232f.jpg\" width=\"440\" height=\"330\" alt=\"Location tracking on TV\" \/><\/a><\/p>\n<p>This is what you see if you press the &#8220;Find Dale&#8221; button on my TV remote control. <\/p>\n<p>(<em>Well, actually the &#8220;Teletext&#8221; button&#8230; cos I wasn&#8217;t using it, and there isn&#8217;t another button that makes any more sense!<\/em>)<\/p>\n<p>The on-screen-display adds a message at the bottom of the screen for a few seconds, saying my last recorded location and when I was there.  <\/p>\n<p>People following <a href=\"http:\/\/twitter.com\/dalelane\" target=\"_blank\">me on twitter<\/a> may have noticed me talking about setting up a new home media server: a small Linux server that has become our Freeview box, <a target=\"_blank\" href=\"http:\/\/en.wikipedia.org\/wiki\/Digital_video_recorder\">PVR<\/a>, home photo album, and music server. <\/p>\n<p>And now it&#8217;s set up, it is surprisingly easy to do amazingly useful, and not-at-all annoying things like this! \ud83d\ude09<\/p>\n<p><em>In my defence, I stopped just short of making the script poll for my location and display an on-screen message whenever my location changes. Which would&#8217;ve been very cool, but probably drive my family nuts. So I compromised with a script that runs when you press a button on the remote.<\/em><\/p>\n<p><!--more-->There are three bits to this:<\/p>\n<ol>\n<li>Getting my location\n<\/li>\n<li>Putting my location on the TV screen\n<\/li>\n<li>Getting this to happen when you press a button on the remote\n<\/li>\n<\/ol>\n<p><strong>Getting my location<\/strong><\/p>\n<p>I use the <a href=\"http:\/\/www.google.com\/latitude\/apps\/badge\">Google Latitude badge<\/a> that I <a href=\"http:\/\/www.google.com\/latitude\/apps\/badge\/api?user=-4899040162740511709&#038;type=iframe&#038;maptype=roadmap\" target=\"_blank\">embed in my blog<\/a> to share my Latitude location, and scrape it to get my location information. <\/p>\n<p>Bit of a cludgy and brittle hack, but this will do for my needs.<\/p>\n<p><strong>Putting my location on the TV screen<\/strong><\/p>\n<p>I&#8217;m using <a href=\"http:\/\/www.linuxtv.org\/vdrwiki\/index.php\/Main_Page\" target=\"_blank\">VDR<\/a> as the base for our media server. (I was originally gonna use MythTV because I&#8217;d heard of it before, but Dom <a target=\"_blank\" href=\"http:\/\/twitter.com\/oldmanuk\/status\/4479673357\">pointed me<\/a> <a target=\"_blank\" href=\"http:\/\/twitter.com\/oldmanuk\/status\/4480002759\">at VDR instead<\/a>). <\/p>\n<p>One of the things it supports is <a href=\"http:\/\/www.linuxtv.org\/vdrwiki\/index.php\/Svdrp\" target=\"_blank\">svdrp<\/a> &#8211; basically it listens on port 2001 for commands. You can send it <a href=\"http:\/\/www.linuxtv.org\/vdrwiki\/index.php\/Svdrp#The_commands\" target=\"_blank\">commands to do anything<\/a>, such as change channels. <\/p>\n<p>One of the svdrp commands is <code>MESG<\/code>:<\/p>\n<blockquote><p>Displays the given message on the OSD. If message is omitted, the currently pending message (if any) will be returned. The message will be displayed for a few seconds as soon as the OSD has become idle. If a new MESG command is entered while the previous message has not yet been displayed, the old message will be overwritten.<\/p><\/blockquote>\n<p>.<br \/>\nRunning:<\/p>\n<pre style=\"overflow: scroll; font-size: 1.1em; border: thin solid silver; background-color: #eeeeee; padding: 0.8em\">svdrpsend MESG \"Hello World\"<\/pre>\n<p>will display &#8220;Hello World&#8221; on your TV.<\/p>\n<p>And so running:<\/p>\n<pre style=\"overflow: scroll; font-size: 1.1em; border: thin solid silver; background-color: #eeeeee; padding: 0.8em\">svdrpsend MESG `python \/home\/dale\/scripts\/googlatitude.py`<\/pre>\n<p>displays the output of my Python script (which is what downloads the contents of my Latitude embed page, scrapes the text description of my location and prints it to stdout). <\/p>\n<p>Running this command displays my location on the TV. <\/p>\n<p><strong>Getting this to happen when you press a button on the remote<\/strong><\/p>\n<p>The last bit is getting this command to run from the remote control. <\/p>\n<p>The vdr installer also installed <a href=\"http:\/\/www.lirc.org\/\" target=\"_blank\">LIRC<\/a> which handles decoding instructions from my infra-red remote control. <\/p>\n<p>As a result, I already had a <code>lircd<\/code> daemon running, and the runvdr script that starts vdr uses the <code>--lirc<\/code> switch to enable lirc support.<\/p>\n<p>The file <code>\/var\/lib\/vdr\/remote.conf<\/code> maps buttons on the physical remote (identified in <code>\/etc\/lirc\/lircd.conf<\/code>) to functions in VDR. I chose one of the buttons not used by VDR (and not mentioned in <code>\/var\/lib\/vdr\/remote.conf<\/code>) &#8211; &#8220;Teletext&#8221;. <\/p>\n<p>I use <a target=\"_blank\" href=\"http:\/\/www.lirc.org\/html\/irexec.html\">irexec<\/a> to use the remote to run other non-VDR commands. <\/p>\n<p>Firstly, I create the file <code>~\/.lircrc<\/code> with the following:<\/p>\n<pre style=\"overflow: scroll; font-size: 1.1em; border: thin solid silver; background-color: #eeeeee; padding: 0.8em\">begin\r\n   button = Teletext\r\n   prog = irexec\r\n   config = svdrpsend mesg `python \/home\/dale\/scripts\/googlatitude.py` &\r\n   flags = quit\r\nend<\/pre>\n<p>Then I start the <a target=\"_blank\" href=\"http:\/\/www.lirc.org\/html\/irexec.html\">irexec daemon<\/a> with <code>irexec --daemon<\/code>. This does the job of running my command when the Teletext button is pressed. <\/p>\n<p>Job done &#8211; location tracking on telly. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is what you see if you press the &#8220;Find Dale&#8221; button on my TV remote control. (Well, actually the &#8220;Teletext&#8221; button&#8230; cos I wasn&#8217;t using it, and there isn&#8217;t another button that makes any more sense!) The on-screen-display adds a message at the bottom of the screen for a few seconds, saying my last [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[158,387,137,428,306,398,427],"class_list":["post-991","post","type-post","status-publish","format-standard","hentry","category-code","tag-google","tag-latitude","tag-location","tag-svdrp","tag-television","tag-tv","tag-vdr"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=991"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/991\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}