Package: samsungtvws
Samsung Smart TV WS API wrapperThis 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 onhttps://github.com/marysieek/samsung-tv-apiworkInstall$pip3installsamsungtvws[async,encrypted]or$pip3install"git+https://github.com/xchwarze/samsung-tv-ws-api.git#egg=samsungtvws[async,encrypted]"or...!$gitclonehttps://github.com/xchwarze/samsung-tv-ws-api
$pip3install"./samsung-tv-ws-api[async,encrypted]"Extrasasyncis required if you wish to use asynchronous I/O for all communications with the TV (SamsungTVAsyncRestandSamsungTVWSAsyncRemote)encryptedis required if you wish to communicate with a TV which only support the v1 API (some J and K models) for sending commands (SamsungTVEncryptedWSAsyncRemoteandSamsungTVEncryptedWSAsyncAuthenticator).UsageBasicimportsysimportosimportloggingimportwakeonlansys.path.append('../')fromsamsungtvwsimportSamsungTVWS# Increase debug levellogging.basicConfig(level=logging.INFO)# Normal constructortv=SamsungTVWS('192.168.xxx.xxx')# Autosave token to filetoken_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 powertv.shortcuts().power()# Power Onwakeonlan.send_magic_packet('CC:6E:A4:xx:xx:xx')# Open web in browsertv.open_browser('https://duckduckgo.com/')# View installed appsapps=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 ModeTVs that support art mode (such as The Frame) can be controlled as follows:importsysimportloggingsys.path.append('../')fromsamsungtvwsimportSamsungTVWS# Increase debug levellogging.basicConfig(level=logging.INFO)# Normal constructortv=SamsungTVWS('192.168.xxx.xxx')# Is art mode supported?info=tv.art().supported()logging.info(info)# List the art available on the deviceinfo=tv.art().available()logging.info(info)# Retrieve information about the currently selected artinfo=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 arttv.art().select_image('SAM-F0206')# Set a piece of art, but don't immediately show it if not in art modetv.art().select_image('SAM-F0201',show=False)# Determine whether the TV is currently in art modeinfo=tv.art().get_artmode()logging.info(info)# Switch art mode on or offtv.art().set_artmode(True)tv.art().set_artmode(False)# Upload a picturefile=open('test.png','rb')data=file.read()tv.art().upload(data)# If uploading a JPEGtv.art().upload(data,file_type='JPEG')# To set the matte to modern and apricot colortv.art().upload(data,matte='modern_apricot')# Delete an uploaded itemtv.art().delete('MY-F0020')# Delete multiple uploaded itemstv.art().delete_list(['MY-F0020','MY-F0021'])# List available photo filtersinfo=tv.art().get_photo_filter_list()logging.info(info)# Apply a filter to a specific piece of arttv.art().set_photo_filter('SAM-F0206','ink')AsyncExamples are available in the examples folder:async_remote.py,async_rest.pyEncrypted APIExamples are available in the examples folder:encrypted_authenticator.py,encrypted_remote.pySupported TVsList of support TV models.https://developer.samsung.com/smarttv/develop/extension-libraries/smart-view-sdk/supported-device/supported-tvs.html2017 : 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 listhttps://developer.samsung.com/smarttv/develop/specifications/tv-model-groups.htmlLicenseGPL-2.0