├── .gitignore ├── package.json ├── README.md └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "homebridge-samsungtv", 3 | "version": "0.0.1", 4 | "description": "Samsung TV plugin for homebridge", 5 | "keywords": [ 6 | "homebridge-plugin", 7 | "homebridge", 8 | "samsung", 9 | "samsung tv", 10 | "tv", 11 | "homekit" 12 | ], 13 | "engines": { 14 | "node": ">=0.12.0", 15 | "homebridge": ">=0.2.0" 16 | }, 17 | "dependencies": { 18 | "samsungtv": "git+ssh://git@github.com/simonbs/samsungtv.git" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # homebridge-samsungtv 2 | 3 | Samsung TV plugin for [Homebridge](https://github.com/nfarina/homebridge). Supports turning on and off the TV using HomeKit and Siri. 4 | 5 | ## Installation 6 | 7 | 1. Install using `npm install -g git+ssh://git@github.com/simonbs/homebridge-samsungtv.git ` 8 | 2. Add your Samsung TV to `~/.homebridge/config.json` as shown below. 9 | 10 | ``` 11 | "accessories": [{ 12 | "accessory": "SamsungTV", 13 | "name": "TV", 14 | "macAddress": "AA:BB:CC:DD:EE:FF", 15 | "ipAddress": "192.168.0.1" 16 | }] 17 | ``` 18 | 19 | 3. Restart homebridge. 20 | 4. Your Samsung TV should now appear in your Home app as a switch. 21 | 22 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var SamsungTV = require("samsungtv"); 2 | var Service, Characteristic; 3 | 4 | module.exports = function(homebridge) { 5 | Service = homebridge.hap.Service; 6 | Characteristic = homebridge.hap.Characteristic; 7 | homebridge.registerAccessory("homebridge-samsungtv", "SamsungTV", SamsungTVAccessory); 8 | } 9 | 10 | function SamsungTVAccessory(log, config) { 11 | this.name = config["name"]; 12 | var port = config["port"] || 8001; 13 | var appName = config["appName"] || "homebridge"; 14 | this.samsungTV = new SamsungTV(config["macAddress"], config["ipAddress"], port, appName); 15 | } 16 | 17 | SamsungTVAccessory.prototype.getServices = function() { 18 | var switchService = new Service.Switch(this.name); 19 | switchService 20 | .getCharacteristic(Characteristic.On) 21 | .on("set", this.setPowerState.bind(this)) 22 | .on("get", this.isOn.bind(this)); 23 | return [ switchService ] 24 | } 25 | 26 | SamsungTVAccessory.prototype.identify = function(callback) { 27 | callback(); 28 | } 29 | 30 | SamsungTVAccessory.prototype.isOn = function(callback) { 31 | return this.samsungTV.isOn(callback); 32 | } 33 | 34 | SamsungTVAccessory.prototype.setPowerState = function(isOn, callback) { 35 | if (isOn) { 36 | this.samsungTV.turnOn(callback); 37 | } else { 38 | this.samsungTV.turnOff(callback); 39 | } 40 | } 41 | --------------------------------------------------------------------------------