• Stars
    star
    245
  • Rank 165,304 (Top 4 %)
  • Language
    Python
  • License
    GNU Lesser Genera...
  • Created about 5 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Samsung Smart TV WS API wrapper


Version Samsung Smart TV WS API wrapper

This project is a library for remote controlling Samsung televisions via a TCP/IP connection.

It currently supports modern (post-2016) TVs with Ethernet or Wi-Fi connectivity. They should be all models with TizenOs.

Based on https://github.com/marysieek/samsung-tv-api work

Install

$ pip3 install samsungtvws[async,encrypted]

or

$ pip3 install "git+https://github.com/xchwarze/samsung-tv-ws-api.git#egg=samsungtvws[async,encrypted]"

or...!

$ git clone https://github.com/xchwarze/samsung-tv-ws-api
$ pip3 install "./samsung-tv-ws-api[async,encrypted]"

Extras

async is required if you wish to use asynchronous I/O for all communications with the TV (SamsungTVAsyncRest and SamsungTVWSAsyncRemote) encrypted is required if you wish to communicate with a TV which only support the v1 API (some J and K models) for sending commands (SamsungTVEncryptedWSAsyncRemote and SamsungTVEncryptedWSAsyncAuthenticator).

Usage

Basic

import sys
import os
import logging
import wakeonlan

sys.path.append('../')

from samsungtvws import SamsungTVWS

# Increase debug level
logging.basicConfig(level=logging.INFO)

# Normal constructor
tv = SamsungTVWS('192.168.xxx.xxx')

# Autosave token to file
token_file = os.path.dirname(os.path.realpath(__file__)) + '/tv-token.txt'
tv = SamsungTVWS(host='192.168.xxx.xxx', port=8002, token_file=token_file)

# Toggle power
tv.shortcuts().power()

# Power On
wakeonlan.send_magic_packet('CC:6E:A4:xx:xx:xx')

# Open web in browser
tv.open_browser('https://duckduckgo.com/')

# View installed apps
apps = tv.app_list()
logging.info(apps)

# Open app (Spotify)
tv.run_app('3201606009684')

# Get app status (Spotify)
app = tv.rest_app_status('3201606009684')
logging.info(app)

# Open app (Spotify)
app = tv.rest_app_run('3201606009684')
logging.info(app)

# Close app (Spotify)
app = tv.rest_app_close('3201606009684')
logging.info(app)

# Install from official store (Spotify)
app = tv.rest_app_install('3201606009684')
logging.info(app)

# Get device info (device name, model, supported features..)
info = tv.rest_device_info()
logging.info(info)

Art Mode

TVs that support art mode (such as The Frame) can be controlled as follows:

import sys
import logging

sys.path.append('../')

from samsungtvws import SamsungTVWS

# Increase debug level
logging.basicConfig(level=logging.INFO)

# Normal constructor
tv = SamsungTVWS('192.168.xxx.xxx')

# Is art mode supported?
info = tv.art().supported()
logging.info(info)

# List the art available on the device
info = tv.art().available()
logging.info(info)

# Retrieve information about the currently selected art
info = tv.art().get_current()
logging.info(info)

# Retrieve a thumbnail for a specific piece of art. Returns a JPEG.
thumbnail = tv.art().get_thumbnail('SAM-F0206')

# Set a piece of art
tv.art().select_image('SAM-F0206')

# Set a piece of art, but don't immediately show it if not in art mode
tv.art().select_image('SAM-F0201', show=False)

# Determine whether the TV is currently in art mode
info = tv.art().get_artmode()
logging.info(info)

# Switch art mode on or off
tv.art().set_artmode(True)
tv.art().set_artmode(False)

# Upload a picture
file = open('test.png', 'rb')
data = file.read()
tv.art().upload(data)

# If uploading a JPEG
tv.art().upload(data, file_type='JPEG')

# To set the matte to modern and apricot color
tv.art().upload(data, matte='modern_apricot')

# Delete an uploaded item
tv.art().delete('MY-F0020')

# Delete multiple uploaded items
tv.art().delete_list(['MY-F0020', 'MY-F0021'])

# List available photo filters
info = tv.art().get_photo_filter_list()
logging.info(info)

# Apply a filter to a specific piece of art
tv.art().set_photo_filter('SAM-F0206', 'ink')

Async

Examples are available in the examples folder: async_remote.py, async_rest.py

Encrypted API

Examples are available in the examples folder: encrypted_authenticator.py, encrypted_remote.py

Supported TVs

List of support TV models. https://developer.samsung.com/smarttv/develop/extension-libraries/smart-view-sdk/supported-device/supported-tvs.html

2017 : M5500 and above
2016 : K4300, K5300 and above
2015 : J5500 and above (except J6203)
2014 : H4500, H5500 and above (except H6003/H6103/H6153/H6201/H6203)
Supported TV models may vary by region.

For complete list https://developer.samsung.com/smarttv/develop/specifications/tv-model-groups.html

License

GPL-2.0

More Repositories

1

Cain

Password recovery tool for Microsoft Operating Systems. It allows easy recovery of various kind of passwords by sniffing the network, cracking encrypted passwords using Dictionary, Brute-Force and Cryptanalysis attacks and more!
PHP
342
star
2

AR150-WiFiPineapple

Converting your AR150 to a Wifi Pineapple NANO
136
star
3

wifi-pineapple-cloner

Port WiFi Pineapple NANO/TETRA in generic hardware
Shell
136
star
4

wifi-pineapple-cloner-builds

Build repo from Universal Wifi pineapple hardware cloner
54
star
5

CCCPShell

PHP Shell with encrypted comunication and other toys
PHP
46
star
6

KIMS

KIMS Multi AV Scanner by DSR!
PHP
29
star
7

wifi-pineapple-panel

Updated panel for Wifi Pineapple NANO/TETRA
HTML
25
star
8

wifi-pineapple-community

WiFi Pineapple MK6 updated content repo
Python
20
star
9

universal-tool-updater

Universal Tool Updater script
Python
17
star
10

frieren

Frieren is a micro-framework designed for use in routers and Single Board Computers (SBCs). This framework is built to be lightweight, efficient, and easy to integrate into various hardware projects.
JavaScript
17
star
11

wifi-pineapple-pmkidattack

Module PMKIDAttack for WiFi Pineapple
JavaScript
12
star
12

SMF2WPBridge

SMF2WPBridge is a simple one way bridge from Simple Machine Forum to Wordpress.
PHP
12
star
13

rats-library

RATs library 2003 to present
11
star
14

WP2SMFBridge

Login bridge for use SMF with WP
PHP
9
star
15

yii2-bootstrap-material-design

Composer package for implementing MDB in Yii2
PHP
7
star
16

GSH

Generic Shell Helper is a swiss knife for your android device
Batchfile
6
star
17

ckeditor-phpbb

CKEditor integration for phpBB
JavaScript
4
star
18

malzilla

Malzilla: Malware hunting tool
Pascal
3
star
19

ideAlarm

Multi Zone Home Alarm Script for Domoticz
Lua
3
star
20

frieren-modules

Collection of modules for the Frieren micro-framework, enhancing functionality for routers and Single Board Computers (SBCs). Explore a range of modules aimed at boosting security, performance, and user experience.
JavaScript
2
star
21

RE2

Rencon engine for webapps
PHP
1
star
22

addon-autossh

Shell
1
star
23

kismet-openwrt-builder

1
star
24

yii2-upload-file-behavior

PHP
1
star
25

frieren-wpmk6

HTML
1
star