npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

samsung-tv

v0.3.1

Published

Module for controlling Samsung TVs via RS232

Downloads

3

Readme

Samsung TV Remote

Module for controlling Samsung TVs via RS232.

RS232 Interface

Many Samsung TVs don't seem to have a standard 9 pin serial port, they usually have a service port of some kind which is either a 3.5mm stereo jack or the PC VGA connector.

For more information on how to create an interface see this post over at SamyGo

I accept no responsibility for any damage done to your computer or TV

Installation

npm install samsung-tv

Usage

var samsungTv = require('samsung-tv');

var tv = new samsungTv({
  port: '' // eg. /dev/ttyS0
});

tv.getSession.on('open', function() {
  // now connected
  // all commands to be placed here
});

Methods

A number of examples can be found within the examples directory.

General

calculateChecksum(array)

Calculate the 7th checksum byte when sending a command to the TV.

Arguments

  • array - Array of 6 bytes

Example

var checksum = tv.calculateChecksum([0x08, 0x22, 0x00, 0x00, 0x00, 0x00]);

send(array, callback)

Send a command via the serial connection.

Arguments

  • array - Array of 6 bytes
  • callback(err) - Called once write has been completed

Example

tv.send([0x08, 0x22, 0x00, 0x00, 0x00, 0x00], function(err) {
  if (err) {
    console.log(err);
    return;
  }
  
  console.log('Sent!');
);

getSession()

Get the current serialport session.


close()

Close the current serialport session.


TV Specific

Note all of the below examples have had their error handling examples removed as they are all identical to:

tv.methodName(function(err) {
  if (err) {
      console.log(err);
      return;
    }
    
    console.log('Sent!');
});

sendPowerToggle(callback)

Toggle the TVs power.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendPowerToggle(function(err) {
  console.log('Sent!');
});

setPower(state, callback)

Set the TVs power to on/off.

Arguments

  • state - bool
  • callback(err) - Optional callback called once write has been completed

Example

Power the TV on

tv.setPower(true, function(err) {
  console.log('Sent!');
});

sendVolumeUp(callback)

Increase the volume by 1.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendVolumeUp(true, function(err) {
  console.log('Sent!');
});

sendVolumeDown(callback)

Decrease the volume by 1.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendVolumeDown(true, function(err) {
  console.log('Sent!');
});

setVolume(volume, callback)

Set the volume to a specific level.

Arguments

  • volume - Integer between 0 and 100
  • callback(err) - Optional callback called once write has been completed

Example

Set the volume to 15

tv.setVolume(15, function(err) {
  console.log('Sent!');
});

sendVolumeMuteToggle(callback)

Toggle mute.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendVolumeMuteToggle(function(err) {
  console.log('Sent!');
});

sendChannelUp(callback)

Go to the next channel in the channel list.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendChannelUp(function(err) {
  console.log('Sent!');
});

sendChannelDown(callback)

Go to the previous channel in the channel list.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendChannelDown(function(err) {
  console.log('Sent!');
});

sendChannelPrevious(callback)

Go to the previous channel.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendChannelPrevious(function(err) {
  console.log('Sent!');
});

setChannel(channel, callback)

Go to a specific channel.

Arguments

  • channel - Channel number (eg 101)
  • callback(err) - Optional callback called once write has been completed

Example

Example to change to BBC HD (in the case of my current channel listing)

tv.setChannel(101, function(err) {
  console.log('Sent!');
});

setSourceTv(callback)

Set the source to TV.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.setSourceTv(101, function(err) {
  console.log('Sent!');
});

setSourceAv(value, callback)

Set the source to AV (1-3).

Arguments

  • value - Which AV channel to use (1-3)
  • callback(err) - Optional callback called once write has been completed

Example

Set the source to AV 1

tv.setSourceAv(1, function(err) {
  console.log('Sent!');
});

setSourceComponent(value, callback)

Set the source to component (1-3).

Arguments

  • value - Which component channel to use (1-3)
  • callback(err) - Optional callback called once write has been completed

Example

Set the source to component 1

tv.setSourceComponent(1, function(err) {
  console.log('Sent!');
});

setSourcePc(callback)

Set the source to PC.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.setSourcePc(101, function(err) {
  console.log('Sent!');
});

setSourceHdmi(value, callback)

Set the source to HDMI (1-4).

Arguments

  • value - Which HDMI channel to use (1-3)
  • callback(err) - Optional callback called once write has been completed

Example

Set the source to HDMI 1

tv.setSourceHdmi(1, function(err) {
  console.log('Sent!');
});

setSourceSmartHub(callback)

Set the source to the Samsung Smart Hub.

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.setSourceSmartHub(101, function(err) {
  console.log('Sent!');
});

setPictureMode(value, callback)

Set the picture mode.

|Value|Mode| |-----|----| |0|Dynamic| |1|Standard| |2|Movie| |3|Natural| |4|Cal night| |5|Cal day| |6|BD Wise|

Arguments

  • value - Picture mode as per table above
  • callback(err) - Optional callback called once write has been completed

Example

Set the picture mode to dynamic

tv.setPictureMode(0, function(err) {
  console.log('Sent!');
});

setBacklight(value, callback)

Set the backlight level (0-20).

Arguments

  • value - Backlight level 0-20
  • callback(err) - Optional callback called once write has been completed

Example

Set the backlight to maximum

tv.setBacklight(20, function(err) {
  console.log('Sent!');
});

setContrast(value, callback)

Set the contrast level (0-100).

Arguments

  • value - Contrast level 0-100
  • callback(err) - Optional callback called once write has been completed

Example

Set the contrast to maximum

tv.setContrast(100, function(err) {
  console.log('Sent!');
});

setBrightness(value, callback)

Set the brightness level (0-100).

Arguments

  • value - Brightness level 0-100
  • callback(err) - Optional callback called once write has been completed

Example

Set the brightness to maximum

tv.setBrightness(100, function(err) {
  console.log('Sent!');
});

setSharpness(value, callback)

Set the sharpness level (0-100).

Arguments

  • value - Sharpness level 0-100
  • callback(err) - Optional callback called once write has been completed

Example

Set the sharpness to maximum

tv.setSharpness(100, function(err) {
  console.log('Sent!');
});

setColour(value, callback)

Set the colour level (0-100).

Arguments

  • value - Colour level 0-100
  • callback(err) - Optional callback called once write has been completed

Example

Set the Colour to maximum

tv.setColour(100, function(err) {
  console.log('Sent!');
});

setTint(value, callback)

Set the tint level (0-100).

Arguments

  • value - Tint level 0-100
  • callback(err) - Optional callback called once write has been completed

Example

Set the tint to maximum

tv.setTint(100, function(err) {
  console.log('Sent!');
});

setPictureBlackTone(mode, callback)

Set the picture black tone.

|Value|Mode| |-----|----| |0|Off| |1|Dark| |2|Darker| |3|Darkest|

Arguments

  • mode - Picture black tone as per table above
  • callback(err) - Optional callback called once write has been completed

Example

Set the picture black tone to off

tv.setPictureBlackTone(0, function(err) {
  console.log('Sent!');
});

setPictureDynamicContrast(mode, callback)

Set the dynamic contrast mode

|Value|Mode| |-----|----| |0|Off| |1|Low| |2|Medium| |3|High|

Arguments

  • mode - Dynamic contrast mode as per table above
  • callback(err) - Optional callback called once write has been completed

Example

Set the dynamic contrast mode to off

tv.setPictureDynamicContrast(0, function(err) {
  console.log('Sent!');
});

setPictureShadowDetail(value, callback)

Set the shadow detail level between -2 and 2

Arguments

  • value - Shawdow detail level between -2 and 2
  • callback(err) - Optional callback called once write has been completed

Example

Set the shadow detail level to 0

tv.setPictureShadowDetail(0, function(err) {
  console.log('Sent!');
});

setPictureGamma(value, callback)

Set the picture gamma level between -3 and 3

Arguments

  • value - Picture gamma level between -3 and 3
  • callback(err) - Optional callback called once write has been completed

Example

Set the picture gamma level to 0

tv.setPictureGamma(0, function(err) {
  console.log('Sent!');
});

setPictureSize(size, callback)

Set the picture size mode

|Value|Mode| |-----|----| |0|16:9| |1|Zoom1| |2|Zoom2| |3|Wide fit| |4|Screen fit| |5|Smart view 1| |6|Smart view 2|

Arguments

  • size - Picture size mode as per table above
  • callback(err) - Optional callback called once write has been completed

Example

Set the picture size to 16:9

tv.setPictureSize(0, function(err) {
  console.log('Sent!');
});

set3DMode(mode, callback)

Set the 3D mode

|Value|Mode| |-----|----| |0|Off| |1|2D -> 3D| |2|Side by side| |3|Top bottom| |4|Line by line| |5|Vertical line| |6|Checker BD| |7|Frame sequence|

Arguments

  • mode - 3D mode as per table above
  • callback(err) - Optional callback called once write has been completed

Example

Set the 3D mode to off

tv.set3DMode(0, function(err) {
  console.log('Sent!');
});

setSoundMode(mode, callback)

Set the sound mode

|Value|Mode| |-----|----| |0|Standard| |1|Music| |2|Movie| |3|Clear voice| |4|Amplify|

Arguments

  • mode - Sound mode as per table above
  • callback(err) - Optional callback called once write has been completed

Example

Set the sound mode to standard

tv.setSoundMode(0, function(err) {
  console.log('Sent!');
});

sendKeyDigit(key, callback)

Send a digit key press (0-9)

Arguments

  • key - Key to send 0-9
  • callback(err) - Optional callback called once write has been completed

Example

Send key 5

tv.sendKeyDigit(5, function(err) {
  console.log('Sent!');
});

sendKeyOk(callback)

Send the ok/enter key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyOk(function(err) {
  console.log('Sent!');
});

sendKeyExit(callback)

Send the exit key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyExit(function(err) {
  console.log('Sent!');
});

sendKeyReturn(callback)

Send the return key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyReturn(function(err) {
  console.log('Sent!');
});

sendKeyMore(callback)

Send the more key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyMore(function(err) {
  console.log('Sent!');
});

sendKeyTools(callback)

Send the tools key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyTools(function(err) {
  console.log('Sent!');
});

sendKeyInfo(callback)

Send the info key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyInfo(function(err) {
  console.log('Sent!');
});

sendKeyGuide(callback)

Send the guide key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyGuide(function(err) {
  console.log('Sent!');
});

sendKeyMenu(callback)

Send the menu key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyMenu(function(err) {
  console.log('Sent!');
});

sendKeyUp(callback)

Send the up key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyUp(function(err) {
  console.log('Sent!');
});

sendKeyDown(callback)

Send the down key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyDown(function(err) {
  console.log('Sent!');
});

sendKeyLeft(callback)

Send the left key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyLeft(function(err) {
  console.log('Sent!');
});

sendKeyRight(callback)

Send the right key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyRight(function(err) {
  console.log('Sent!');
});

sendKeySleepMode(callback)

Send the sleep mode key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeySleepMode(function(err) {
  console.log('Sent!');
});

sendKeyRed(callback)

Send the red button key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyRed(function(err) {
  console.log('Sent!');
});

sendKeyGreen(callback)

Send the green button key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyGreen(function(err) {
  console.log('Sent!');
});

sendKeyYellow(callback)

Send the yellow button key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyYellow(function(err) {
  console.log('Sent!');
});

sendKeyBlue(callback)

Send the blue button key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyBlue(function(err) {
  console.log('Sent!');
});

sendKeyChannelList(callback)

Send the channel list key press

Arguments

  • callback(err) - Optional callback called once write has been completed

Example

tv.sendKeyChannelList(function(err) {
  console.log('Sent!');
});

Notes

Unfortunately due to the non existent documentation and poor implementation of the API by Samsung there is no two way communication supported.

Managed to source a number of RS232 codes off various forum posts, specifically the download available here.

Some considerations and limitations:

  • The RS232 port may need enabling via the service menu
  • Not all TVs can be powered on via RS232
  • Some TVs may not work at all (my 2007 LE40M87 prints output via serial but no control)
  • No two way communication

Licence

The MIT License (MIT)