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]"
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
logging.basicConfig(level=logging.INFO)
tv = SamsungTVWS('192.168.xxx.xxx')
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)
tv.shortcuts().power()
wakeonlan.send_magic_packet('CC:6E:A4:xx:xx:xx')
tv.open_browser('https://duckduckgo.com/')
apps = tv.app_list()
logging.info(apps)
tv.run_app('3201606009684')
app = tv.rest_app_status('3201606009684')
logging.info(app)
app = tv.rest_app_run('3201606009684')
logging.info(app)
app = tv.rest_app_close('3201606009684')
logging.info(app)
app = tv.rest_app_install('3201606009684')
logging.info(app)
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
logging.basicConfig(level=logging.INFO)
tv = SamsungTVWS('192.168.xxx.xxx')
info = tv.art().supported()
logging.info(info)
info = tv.art().available()
logging.info(info)
info = tv.art().get_current()
logging.info(info)
thumbnail = tv.art().get_thumbnail('SAM-F0206')
tv.art().select_image('SAM-F0206')
tv.art().select_image('SAM-F0201', show=False)
info = tv.art().get_artmode()
logging.info(info)
tv.art().set_artmode(True)
tv.art().set_artmode(False)
file = open('test.png', 'rb')
data = file.read()
tv.art().upload(data)
tv.art().upload(data, file_type='JPEG')
tv.art().upload(data, matte='modern_apricot')
tv.art().delete('MY-F0020')
tv.art().delete_list(['MY-F0020', 'MY-F0021'])
info = tv.art().get_photo_filter_list()
logging.info(info)
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
LGPL-3.0