Jay said: I vaguely recall some status commands in the API, but my goal was really just control. I do have a feature request in place to look at adding status (some day).
Taking a break from a plugin project and before I knew what happened, I had this hammered out. This code just logs information reported by the receiver; you'll have to convert the code to write the information to variables or what have you. The only other thing that needs to be adjusted is to enter the IP of the unit in question (DTVIP).
- Code: Select all
#! /usr/bin/env python2.5
# -*- coding: utf-8 -*-
import simplejson
import urllib2
DTVIP = "10.0.1.123"
url = "http://%s:8080/tv/getTuned?" % DTVIP
f = urllib2.urlopen(url)
simplejson_string = f.read()
f.close()
parsed_simplejson = simplejson.loads(simplejson_string)
##### Log the Response #####
indigo.server.log("Query: %s" % parsed_simplejson['status']['query'])
indigo.server.log("Response: %s" % parsed_simplejson['status']['msg'])
indigo.server.log("HTTP Status Code: %s" % parsed_simplejson['status']['code'])
indigo.server.log("Command Result: %s" % parsed_simplejson['status']['commandResult'])
indigo.server.log("Program Title: %s" % parsed_simplejson['title'])
indigo.server.log("Episode Title: %s" % parsed_simplejson['episodeTitle'])
indigo.server.log("Call Sign: %s" % parsed_simplejson['callsign'])
indigo.server.log("Major Channel: %s" % parsed_simplejson['major'])
indigo.server.log("Minor Channel: %s" % parsed_simplejson['minor'])
indigo.server.log("Program Rating: %s" % parsed_simplejson['rating'])
indigo.server.log("DirecTV Station ID: %s" % parsed_simplejson['stationId'])
indigo.server.log("DirecTV Program ID: %s" % parsed_simplejson['programId'])
indigo.server.log("Is Recording: %s" % parsed_simplejson['isRecording'])
indigo.server.log("Is VOD: %s" % parsed_simplejson['isVod'])
indigo.server.log("Start Time: %s" % parsed_simplejson['startTime'])
indigo.server.log("Offset: %s" % parsed_simplejson['offset'])
indigo.server.log("Duration: %s" % parsed_simplejson['duration'])
indigo.server.log("Is Off Air: %s" % parsed_simplejson['isOffAir'])
indigo.server.log("Is PC Locked: %s" % parsed_simplejson['isPclocked'])
Here is sample output:
- Code: Select all
Script Query: /tv/getTuned?
Script Response: OK.
Script HTTP Status Code: 200
Script Command Result: 0
Script Program Title: Blackhawks @ Blue Jackets
Script Episode Title: Chicago Blackhawks at Columbus Blue Jackets
Script Call Sign: WGN
Script Major Channel: 9
Script Minor Channel: 65535
Script Program Rating: No Rating
Script DirecTV Station ID: 3223469
Script DirecTV Program ID: 13697247
Script Is Recording: False
Script Is VOD: False
Script Start Time: 1419120000
Script Offset: 7718
Script Duration: 9000
Script Is Off Air: False
Script Is PC Locked: 3
This has been tested with an HR-34. There is other information that the query might return depending on what the receiver is doing (i.e., playing a recording, playing a music channel, etc.) This was watching live programming.
Cheers,
Dave