Giter Club home page Giter Club logo

bravia's Introduction

Sony BRAVIA

Node.js module for discovering and controlling Sony BRAVIA Android TVs. This module allows you retrieve all the available service protocol API methods and invoke any of them.

Setup

TV Setup

  • Turn on your TV
  • On the TV go to Settings > Network > Home network setup > Remote device/Renderer > On
  • On the TV go to Settings > Network > Home network setup > IP Control > Authentication > Normal and Pre-Shared Key
  • On the TV go to Settings > Network > Home network setup > Remote device/Renderer > Enter Pre-Shared Key > 0000 (or whatever you want your PSK Key to be)
  • On the TV go to Settings > Network > Home network setup > Remote device/Renderer > Simple IP Control > On

Install with NPM

npm install bravia --save

Usage

All methods return a Promise.

Discovery

const Bravia = require('bravia');

// The time in milliseconds for the bravia discovery to scan for.
let timeout = 5000;

// Attempts to discover any Sony Bravia TVs.
Bravia.discover(timeout)
  .then(devices => {
    for (let device in devices) {
      console.log(devices[device]);
    }
  })
  .catch(error => console.error(error));

Service Protocol APIs

const Bravia = require('bravia');

// Connects to a Bravia TV at 192.168.1.2:80 with the PSK 0000.
let bravia = new Bravia('192.168.1.2', '80', '0000');

// Retrieves all the system method type versions.
bravia.system.getVersions()
  .then(versions => console.log(versions))
  .catch(error => console.error(error));

// Retrieves all the system method types and versions.
bravia.system.getMethodTypes()
  .then(methods => console.log(methods))
  .catch(error => console.error(error));

// Retrieves all the available IRCC commands from the TV.
bravia.system.invoke('getRemoteControllerInfo')
  .then(commands => console.log(commands))
  .catch(error => console.error(error));

// Queries the volume info.
bravia.audio.invoke('getVolumeInformation')
  .then(info => console.log(info))
  .catch(error => console.error(error));

// Sets the speaker volume level to 50%.
bravia.audio.invoke('setAudioVolume', '1.0', { target: 'speaker', volume: '50' });

Send IRCC Code

const Bravia = require('bravia');

// Connects to a Bravia TV at 192.168.1.2:80 with the PSK 0000.
let bravia = new Bravia('192.168.1.2', '80', '0000');

// Retrieves all the available IRCC commands from the TV.
bravia.getIRCCCodes()
  .then(commands => console.log(commands))
  .catch(error => console.error(error));

// Sends an IRCC code signal by name.
bravia.send('Mute');

// Sends an IRCC code signal by value.
bravia.send('AAAAAQAAAAEAAAAUAw==');

// Sends multiple IRCC code signals by name and/or value. Change bravia.delay to alter time between each command sent.
bravia.send(['Hdmi1', 'AAAAAgAAABoAAABaAw==', 'Hdmi2', 'AAAAAgAAABoAAABbAw==']);

bravia's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar efa2000 avatar janu75 avatar mergify[bot] avatar phillipsnick avatar waynehaffenden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bravia's Issues

crash when statusCode 404

When I try to get a list of methods using a protocol that the device does not support, the application crashes
for example
I'm trying to get bravia.recording.getMethodTypes ()
device responds with code 404
and the application crashes with an error

TypeError: Cannot read property 'error' of undefined
at Request._callback (...../node_modules/bravia/src/bravia.js:187:27)

Info for invokes

Hi! (this is not a issue)
I'm doing a express webapp to use the bravia module provided by you, I'm wondering how you know the syntax for the method calls:
bravia.audio.invoke('setAudioVolume', '1.0', { target: 'speaker', volume: 50 });
Particularly the { target: 'speaker', volume: 50 } part.
Is there any source for this information?
I'm particularly interested in the syntax for the audio getSpeakerSettings method.

I'm planning to publish my app on github when I clean up the code.

Thanks in advance.

PIN Authentication

Implement PIN authentication in a way that allows a user to transparently use either PIN or Pre-Shared Key authentication without making the API difficult or awkward to use.

We should allow the user to specify the authentication level that their application requires rather than always assuming the highest level "private".

I feel this is going to be a fair re-write of the code on how it currently stands and so this needs to be thought through on how best to accomplish this properly.

Invoke Method Improvement

Re-write the invoke method to use the newer API discovery method, this should greatly enhance performance.

Fully Document API

Initially using the Wiki on this repository, document all the API protocols, versions, methods, parameters and responses using what we know and from contributions from others who have explored the API in more detail.

It may possibly make sense in the future based upon the poor documentation support from Sony to host an external Wiki website so that this documentation is not just associated with this module or implementation.

Static/Hard-Coded API Methods?

Currently, this module just provides an invoke method so that any method from any version and protocol can be invoked without having each one being statically defined. The idea behind this is that no matter what firmware version or model you have the methods you have available to you are the ones you can invoke.

I wonder if it will make this module much easier to use if we define all the API methods and just throw a "not supported" exception for methods that might not actually be available? We could still provide the invoke method and under the hood could use the invoke method so they just become syntactical sugar in reality.

Issue Sending Pic Off IRCC

First off Wayne, your module saved me an incredible amount of time. So Thank You! While working with the code found an issue that may be in your module or in the Sony itself - not sure. I've been working with JS and Node less than a month so what do I know?! The code equivalent for the Picture Off (Pic Off) button on the remote isn't listed on Sony's developer site. I retrieved all codes using the getRemoteControllerInfo though and came up two text options both having the same IRCC:

{ name: 'PicOff', value: 'AAAAAQAAAAEAAAA+Aw==' }

{ name: 'PictureOff', value: 'AAAAAQAAAAEAAAA+Aw==' }

I thought that I would share with you and folks that may care that the only working option (for my Bravia anyway) is to use bravia.send('PicOff'); Sending the code will not work and sending 'PictureOff' text will not work. This may vary by model.

Thanks again for your work. Curt

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.