I am in the process of building a DirecTV remote using HTTP requests. I got all of the remote buttons mapped and working correctly. However, now I am working with receiving the JSON data back from the DirecTV receiver and displaying it correctly.
What I am trying to accomplish is every minute OpenHAB will send the HTTP request to display what is playing on the TV.
Here is the JSON response from the DirecTV Reciever:
{
"callsign": "ESPNHD",
"date": "20170916",
"duration": 10800,
"isOffAir": false,
"isPclocked": 3,
"isPpv": false,
"isRecording": false,
"isVod": false,
"major": 206,
"minor": 65535,
"offset": 10521,
"programId": "64781638",
"rating": "No Rating",
"startTime": 1505566800,
"stationId": 2220255,
"status": {
"code": 200,
"commandResult": 0,
"msg": "OK.",
"query": "/tv/getTuned"
},
"title": "College GameDay"
}
Here is an example of my Rules file:
// DirecTV
rule “DirecTV Watching”
when Time cron "0 0/1 0 ? * * *"
then
String DirecTV_Status = { http="<[http://192.168.1.10:8080/tv/getTuned:60000:REGEX((.*))]" }
var String DIRECTV_POST = DirecTV_Status.state.toString
var String DirecTV_Show = transform("JSONPATH","$.title", DIRECTV_POST)
var String DirecTV_Ch = transform("JSONPATH","$.major", DIRECTV_POST)
var String DirecTV_Chan = transform("JSONPATH","$.callsign", DIRECTV_POST)
var String EPISODE = transform("JSONPATH","$.episodeTitle", DIRECTV_POST)
end
Here is my Items file:
String DirecTV_Show "Watching: [%s]"
String DirecTV_Ch "Current Channel [%s]"
String DirecTV_Chan "Channel: [%s]"
String EPISODE "Episode: [%s]"
Any help would be greatly appreciated! Also, If anyone would like to see my .items file for the rest of my DirecTV configuration, just let me know. I’m thinking of writing a guide on it if there is enough interest.
Thanks,
Trevor