Giter VIP home page Giter VIP logo

homebridge-directv's Introduction

Homebridge-directv

NPM Version

DirecTV plugin for Homebridge Leverages directv-remote

This plugin allows you to control your DirecTV with HomeKit and Siri.

Installation

  1. Install homebridge using: npm install -g homebridge
  2. Install this plugin using: npm install -g homebridge-directv
  3. Update your configuration file like the example below.
  4. Make sure to enable external device access on your cable box: Menu > Settings > Whole-Home > External Device > Allow

This plugin is a Platform and it will show the Primary STB (Set Top Box) (the one with the ip address)as a Switch.
It will also auto detect all Geni STB's and show them as Motion Sensors (since they cannot be powered on/off due to a limitation with the Geni STBs).
In both cases, you can change the channel in the room using an app like Eve (Elagato) via the slider (a bit challenging) or you can tune the device to a favorite channel and then create a scene like "Channel 4" or "NBC".
Scenes created in Eve will show up in the Apple Home app and give the ability to tell Siri to "Set Channel 4" or "Set NBC"!

Configuration

Example config.json:

    "platforms": [
		{
			"platform": "Directv",
			"name": "DTV",
			"ip_address": "192.168.1.101",
			"exclude_geni": true,
			"min_channel": 1,
			"max_channel": 575
		}
	],

Explanation:

Field Description
platform Must always be "Directv". (required)
name The name you want to use for control the DTV accessories. (Optional) This parameter defaults to DTV and is appended to the LocationName defined on your STB to produce the full accessory Name.
ip_address The internal ip address of your Primary DTV STB (Set Top Box).
exclude_geni (Optional) boolean for excluding non-primary STBs (Geni's) so accessories are not created for them. If true, will only create accessory for primary bound tuner STB. Defaults to false.
min_channel (Optional) Starting number for channel slider. Defaults to 1.
max_channel (Optional) Ending number for channel slider. Defaults to 575. Can be used to select higher channel numbers and ease selection for scenes.

Limitations:

Power only works for the primary STB (the one with the IP). Apple Home app cannot change channels without first creating a scene in an app like Eve (Elagato). To allow for ease of setting up channel scenes: 1) Temporarily set reasonable values for min/max channel config settings; 2) Restart homebridge, setup channel scenes in that range; 3) Repeast steps 1-2 as needed; 4) Finally update config with min value of 1 and max of 9999, then restart homebridge. All scenes should work fine.

homebridge-directv's People

Contributors

apexad avatar toddgreenfield avatar

Stargazers

 avatar

Watchers

 avatar  avatar

homebridge-directv's Issues

Crash on loading in Home

I get periodic crashes when opening the Home app in IOS.

directv-remote/index.js line 311, callback (null, parsedBody)

This callback has already been called by someone else, it can only be called one time.

Crash

Apr 22 08:05:40 raspberrypi homebridge[16110]: [4/22/2017, 8:05:40 AM] [DIRECTV] Unable to call for current channel.
Apr 22 08:05:40 raspberrypi homebridge[16110]: [4/22/2017, 8:05:40 AM] [DIRECTV] Current Channel is 0
Apr 22 08:05:40 raspberrypi homebridge[16110]: /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:12
Apr 22 08:05:40 raspberrypi homebridge[16110]: throw new Error("This callback function has already been called by someone else; it can only be called one time.");
Apr 22 08:05:40 raspberrypi homebridge[16110]: ^
Apr 22 08:05:40 raspberrypi homebridge[16110]: Error: This callback function has already been called by someone else; it can only be called one time.
Apr 22 08:05:40 raspberrypi homebridge[16110]: at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:12:13
Apr 22 08:05:40 raspberrypi homebridge[16110]: at /usr/lib/node_modules/homebridge-directv/index.js:101:7
Apr 22 08:05:40 raspberrypi homebridge[16110]: at /usr/lib/node_modules/homebridge-directv/node_modules/directv-remote/index.js:264:21
Apr 22 08:05:40 raspberrypi homebridge[16110]: at IncomingMessage.<anonymous> (/usr/lib/node_modules/homebridge-directv/node_modules/directv-remote/index.js:311:17)
Apr 22 08:05:40 raspberrypi homebridge[16110]: at emitNone (events.js:91:20)
Apr 22 08:05:40 raspberrypi homebridge[16110]: at IncomingMessage.emit (events.js:185:7)
Apr 22 08:05:40 raspberrypi homebridge[16110]: at endReadableNT (_stream_readable.js:974:12)
Apr 22 08:05:40 raspberrypi homebridge[16110]: at _combinedTickCallback (internal/process/next_tick.js:74:11)
Apr 22 08:05:40 raspberrypi homebridge[16110]: at process._tickCallback (internal/process/next_tick.js:98:9)

Investigate making Non-Primary STB (Geni) into Sensors

I mentioned this in a PR, but figured it was better documented as a separate issue. Since the Non-Primary STBs cannot actually be power cycled, a switch does not make sense.

It would be better to implement these as sensors, so that the status is visible, but there is no ability to turn them off or on.

Constantly getting Error in log

I am getting the following errors constantly in the logs. I have the current DirecTV genie 2 system with 2 wired and 1 wireless clients. I am running version 1.0.5 of the DirecTV plugin.

3/20/2022, 12:36:55 AMDirectv BridgeLoaded plugin 'homebridge-directv'
3/20/2022, 12:36:55 AMDirectv BridgeLoading 1 platforms...
3/20/2022, 12:36:55 AMDirectv BridgeDTVFetching DTV locations.
3/20/2022, 12:36:55 AMDirectv BridgeDTVFinding DTV Locations (accessories)...
3/20/2022, 12:36:55 AMDirectv BridgeDTVFound DTV Location LIV
3/20/2022, 12:36:55 AMDirectv BridgeDTVFound DTV Location MBED
3/20/2022, 12:36:55 AMDirectv BridgeDTVFound DTV Location OFFICE
3/20/2022, 12:36:55 AMDirectv BridgeDTVFound DTV Location Server
3/20/2022, 12:36:56 AMDirectv BridgeBridge is running on port 51866.
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Liv DTV@Liv DTV@Channel] characteristic was supplied illegal value: number 0 exceeded minimum of 1
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Liv DTV@Liv DTV@Channel] characteristic was supplied illegal value: number 0 exceeded minimum of 1
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Server DTV@Server DTV@Channel] characteristic was supplied illegal value: number 0 exceeded minimum of 1
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Server DTV@Server DTV@Channel] characteristic was supplied illegal value: number 0 exceeded minimum of 1
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Office DTV@Office DTV@Channel] characteristic was supplied illegal value: number 0 exceeded minimum of 1
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Office DTV@Office DTV@Channel] characteristic was supplied illegal value: number 0 exceeded minimum of 1
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Mbed DTV@Mbed DTV@Channel] The read handler for the characteristic 'Channel' was slow to respond!
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Mbed DTV@Mbed DTV@Channel] The read handler for the characteristic 'Channel' was slow to respond!
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Mbed DTV@Mbed DTV@Channel] characteristic was supplied illegal value: number 0 exceeded minimum of 1
3/20/2022, 12:37:00 AMDirectv BridgeERROR[Directv Bridge D999@Mbed DTV@Mbed DTV@Channel] characteristic was supplied illegal value: number 0 exceeded minimum of 1```

Exposing other buttons

It would be interesting to expose othe buttons, like Guide, List, Channel Up, Channel Down, and the Arrow keys. These switches would need to turn on, do the action, then shut off again in about 500 milliseconds in my testing.
It would allow a room to be created that could look something like this:
img_0991

Multiple DVRs

I have multiple DVRs, an HR54 with several clients (genie mini( which I am able to successfully operate and 4 additional HR24 DVRs. I have added an additional platform each of the additional DVRs however it appears they are not detected. I have confirmed external access is allowed and I am able to issue ip commands from other platforms.

[4/22/2017,` 5:30:50 PM] [MB HR24] Failed to find any DTV Locations (accessories) - Check IP address in config.json!
/usr/lib/node_modules/homebridge/lib/server.js:358
      for (var i = 0; i < foundAccessories.length; i++) {
                                          ^

TypeError: Cannot read property 'length' of null
    at Server.<anonymous> (/usr/lib/node_modules/homebridge/lib/server.js:358:43)
    at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:16:19
    at /usr/lib/node_modules/homebridge-directv/index.js:58:5
    at /usr/lib/node_modules/homebridge-directv/node_modules/directv-remote/index.js:262:21
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/homebridge-directv/node_modules/directv-remote/index.js:306:25)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:188:7)
    at endReadableNT (_stream_readable.js:975:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

Max Channel is 575

It looks like the highest channel per the slider in new scene is 575. Directv has channels up to 9999.

I'd guess the sensitivity of the slider needed to be cut off which is why its at 575. Is there a work around for this?

Wrong device type

Hi! I installed the plugin on homebridge and it detected my devices normally, but the main device he detected as an interruptor and the other devices as a motion sensor on my homebridge and homekit app. It's normal?

Constantly getting Error in log

[8/25/2021, 8:44:13 AM] [homebridge-directv] This plugin generated a warning from the characteristic 'Channel': characteristic was supplied illegal value: number 0 exceeded minimum of 1. See https://git.io/JtMGR for more info.

Can we get this fixed somehow?

incorrect registration error

I'm getting this when rebooting homebridge:

[4/15/2022, 12:05:39 PM] Plugin 'homebridge-directv' tried to register with an incorrect plugin identifier: 'homebridge-directv-location'. Please report this to the developer!

Older DirecTV STBs with IP interfaces should work, and there can be multiple STBs, each with its own IP. At least here, they do not. I provide details.

So my equipment is old as dirt. I'll own up to that - but the json API is the same to my eye. Here's the output of my living room STB:

pi@homebridge:~/scripts/directv$ curl http://172.16.30.79:8080/info/getOptions | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5873  100  5873    0     0  20607      0 --:--:-- --:--:-- --:--:-- 20679
{
  "options": [
    {
      "command": "/info/getLocations",
      "description": "List of available client locations. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        }
      ]
    },
    {
      "command": "/info/getSerialNum",
      "description": "STB serial number. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "clientAddr",
          "type": "string"
        }
      ]
    },
    {
      "command": "/info/getVersion",
      "description": "Set-top-box and SHEF information. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        }
      ]
    },
    {
      "command": "/info/mode",
      "description": "Set-top-box mode. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "clientAddr",
          "type": "string"
        }
      ]
    },
    {
      "command": "/remote/processKey",
      "description": "Process a key request from the remote control. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "clientAddr",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "hold",
          "type": "string"
        },
        {
          "isRequired": true,
          "name": "key",
          "type": "string"
        }
      ]
    },
    {
      "command": "/serial/processCommand",
      "description": "Process a command request from remote control. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        },
        {
          "isRequired": true,
          "name": "cmd",
          "type": "hex"
        }
      ]
    },
    {
      "command": "/tv/getProgInfo",
      "description": "Program information of specified channel at current or specific time. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "minor",
          "type": "int"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        },
        {
          "isRequired": true,
          "name": "major",
          "type": "int"
        },
        {
          "isRequired": false,
          "name": "clientAddr",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "time",
          "type": "long"
        }
      ]
    },
    {
      "command": "/tv/getTuned",
      "description": "Information about the currently viewed program. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "videoWindow",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "clientAddr",
          "type": "string"
        }
      ]
    },
    {
      "command": "/tv/tune",
      "description": "Tune to a channel. Warning: This command may change or be disabled in the future.",
      "formControls": [],
      "urlParameters": [
        {
          "isRequired": false,
          "name": "wrapper",
          "type": "string"
        },
        {
          "isRequired": false,
          "name": "minor",
          "type": "int"
        },
        {
          "isRequired": false,
          "name": "callback",
          "type": "string"
        },
        {
          "isRequired": true,
          "name": "major",
          "type": "int"
        },
        {
          "isRequired": false,
          "name": "source",
          "type": "int"
        },
        {
          "isRequired": false,
          "name": "clientAddr",
          "type": "string"
        }
      ]
    }
  ],
  "status": {
    "code": 200,
    "commandResult": 0,
    "msg": "OK.",
    "query": "/info/getOptions"
  }
}

Each of my 4 (yes, 4) STBs has their own IP address and respond almost identically. They're listening on port 8080 (from what I can tell, this is what the directv-remote module defaults to as well). I've tried setting with and without geni, and I've only been trying to get one working, as I am about 99% sure you didn't count on a situation with multiple STBs with their own IP addresses.

Just the same, here's the config I have in homebridge:

		{
			"platform": "Directv",
			"name": "DTV",
			"ip_address": "172.16.30.79",
			"exclude_geni": false,
			"min_channel": 1,
			"max_channel": 575
		}

Relaunch homebridge, and it will cause this error (tried with and without specifying port number, same results):

[10/19/2020, 10:59:35] Plugin 'homebridge-directv' tried to register with an incorrect plugin identifier: 'homebridge-directv-location'. Please report this to the developer!
[10/19/2020, 10:57:11] [DTV] Initializing Directv platform...
[10/19/2020, 10:57:11] [DTV] Fetching DTV locations.
10/19/2020, 10:57:11] Loading 10 accessories...
[10/19/2020, 10:58:39] [DTV] Finding DTV Locations (accessories)...
[10/19/2020, 10:58:39] TypeError: Cannot read property 'length' of undefined
    at /usr/local/lib/node_modules/homebridge-directv/index.js:48:40
    at /usr/local/lib/node_modules/homebridge-directv/node_modules/directv-remote/index.js:264:21
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/homebridge-directv/node_modules/directv-remote/index.js:311:17)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1223:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
[10/19/2020, 11:01:20] [DTV] Failed to find any DTV Locations (accessories) - Check IP address in config.json!
[10/19/2020, 10:58:39] Got SIGTERM, shutting down Homebridge...

Ignore the timestamps. This is a patchwork copy and paste out of my logs. There's better ways to do it, but I need more coffee.

What appears to be happening is that the directv-remote module is attempting to pull this:

pi@homebridge:~/scripts/directv$ curl http://172.16.30.79:8080/info/getLocations | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   195  100   195    0     0   1772      0 --:--:-- --:--:-- --:--:--  1772
{
  "locations": [
    {
      "clientAddr": "0",
      "locationName": "LIVING ROOM"
    }
  ],
  "status": {
    "code": 200,
    "commandResult": 0,
    "msg": "OK.",
    "query": "/info/getLocations"
  }
}
  • and it is somehow failing out with the "length undefined" you see above. I can't fathom for the life of me why that might be, but it isn't for lack of looking:

https://github.com/cmrust/directv-remote/blob/master/index.js

It's at the very top of the file. The module validates the IP address by pulling exactly what I just pulled, and clearly it pulls valid json back and so far as I can tell, it should be found. I'm completely baffled. I was hoping if I opened an issue with this, your familiarity with how this thing ticks might ring some bells as to what could be so far off here as to break things outright. My gut says that it is failing due to using the default port of 80 instead of 8080, but that doesn't immediately add up, because if you look at the very top of the directv-remote module, you have this bit:

    var options = {
        hostname: IP_ADDRESS,
        port: 8080,
        path: '/info/getLocations'
    };

I'm at a point now where I'm likely to run a tcpdump and see if I can capture precisely what is getting sent to my STB, but this is just feels ridiculous. Got any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.