pysamsungtv
pysamsungtv is an async Python library that talks to Samsung TVs over HTTPS JSON-RPC.
Why
Samsung, in their infinite wisdom, disabled ports 8001 and 8002. This breaks the existing Home Assistant integration/libraries for all 2024+ models. They still expose their JSON-RPC over port 1516/1515, but it is undocumented.
I got frustrated enough to do a clean-room implemenation of it here.
Installation
# pypi
pip install pysamsungtv
# local dev
just install
The package depends on aiohttp for HTTP/1.1 TLS transport. TLS verification is disabled by default because Samsung panels present self-signed certificates; set verify_ssl=True when the certificate chain is trusted on your host.
Usage
Check tests for example usage.
Every helper method corresponds to the JSON-RPC methods in the protocol notes (e.g. get_tv_states, direct_channel_control, volume_up_down, remote_key_control, sound_mode_control, etc). Each coroutine returns the parsed result body or raises a SamsungTVError subclass on transport/protocol failures. Custom RPCs can be issued with SamsungTVClient.send_request().
The optional on_update callback is invoked sequentially after every response. It receives the RPC method name and the parsed payload, making it easy to wire into Home Assistant's entity update routines.
Development
- Install and run
pre-commit(pip install pre-commit && pre-commit install) to ensuremypyandpytestpass locally before committing. - All code is typed and passes
mypyusing the configuration inpyproject.toml. - Run the test suite with
pytest. Unit tests use fully mocked transports. - Integration tests require a real TV: set
SAMSUNG_TV_HOST(plus optionalSAMSUNG_TV_PORTand/orSAMSUNG_TV_TOKEN) and runpytest -m integration. If no token is supplied the first run will prompt for authorization and cache the returned token under.pytest_cache/samsung_tv_tokenfor later runs. - A
Justfileis included for convenience:just install,just install-tests,just test,just mypy, etc. - All command inputs are exposed as enums in
pysamsungtv.enums(also re-exported at the package root) so you can rely on autocomplete/validation for things likeInputSource,PictureMode,SoundMode, andRemoteKey. - Convenience helpers such as
set_picture_mode,set_sound_mode,select_speaker,select_input_source,set_volume,mute()/unmute(), andart_mode_on()/art_mode_off()call the corresponding*_controlRPCs for you.
Metadata
Release files for py-samsungtv 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_samsungtv-1.0.2.tar.gz | 10.5 kB | With provenance | Details for py_samsungtv-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_samsungtv-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for py_samsungtv-1.0.2-py3-none-any.whl |
Total release size: 22.0 kB
Release files / py_samsungtv-1.0.2.tar.gz
| Download URL | py_samsungtv-1.0.2.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08c55d4b48991d09d00ad4d40bfcf5730b59d9e5d84f80af380a0b4c12c97e7b
|
|
BLAKE2b-256 checksum How to use checksums |
1524a36faef4b8c9151166a31e05de3234154f9390f93d5c97ffe3058f316e0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2025.
Transparency logRelease files / py_samsungtv-1.0.2-py3-none-any.whl
| Download URL | py_samsungtv-1.0.2-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61e4dfcf89e74f3e67b872889be982bb064967ba3885de18f22043fe1c824078
|
|
BLAKE2b-256 checksum How to use checksums |
24eed76d65bf7008aae3f91eb5ec6808d6f6f449ee15d0ec91a9f8c539e29847
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2025.
Transparency logSecurity for py-samsungtv 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for py_samsungtv-1.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.