Library built on AsyncIO for communicating with Samsung Wireless Audio speakers (WAM).
Project description
pywam
pywam is an fast and lightweight python asyncio library without external dependencies for communicating with Samsung Wireless Audio (R) speakers (WAM). It was developed to be used for integrating the speakers in Home Assistant with the Samsung Wireless Audio Integration
[!IMPORTANT] This library only supports speakers that can be controlled by the Wireless Audio-Multiroom (Android) or Wireless Audio : Multiroom (iOS). This library will never support speakers not supported by the native Multiroom App. Check src/pywam/device.py to see which speakers are tested and which are believed to work.
Features
- Control Samsung Multiroom speakers.
- Keep track of the state of Samsung Multiroom speakers.
Limitations
The SetUrlPlayback API used to get the speakers playing url streams is only partially implemented in the speakers. I have found information that not all speakers accept it, and the one that does will only play the url. The speaker will not report that it is playing a url. This means that as soon as the speakers is asked for current state it will report that it is not playing anything, which this library will pick up and believe to be true.
Installation
pip install pywam
Usage
Set the speaker volume to 50% with python context manager:
from pywam.speaker import Speaker
async with Speaker('192.168.1.100') as speaker:
await speaker.update()
await speaker.set_volume(50)
Example of controlling media playback:
# Play
await speaker.cmd_play()
# Pause
await speaker.cmd_pause()
# Shuffle mode
await speaker.set_shuffle(True)
Example of playing a url stream:
from pywam.lib.url import UrlMediaItem
item = UrlMediaItem('http://live-bauerse-fm.sharp-stream.com/retrofm_mp3')
await speaker.play_url(item)
Example of group handling:
from pywam.speaker import Speaker
kitchen = Speaker('192.168.1.50')
await kitchen.connect()
await kitchen.update()
bedroom = Speaker('192.168.1.51')
await bedroom.connect()
await bedroom.update()
bathroom = Speaker('192.168.1.52')
await bathroom.connect()
await bathroom.update()
# Group bathroom with kitchen as master
await kitchen.group([], [bathroom])
# Add bedroom to the group
await kitchen.group([bathroom], [bathroom, bedroom])
# Remove bathroom from group
await kitchen.group([bathroom, bedroom], [bedroom])
# Ungroup
await kitchen.group([bedroom], [])
Get notifications about speakers state changes:
from pywam.speaker import Speaker
def state_receiver(event):
print(event)
speaker = Speaker('192.168.1.150')
speaker.events.register_subscriber(state_receiver, 2)
await speaker.connect()
await speaker.update()
For more examples please check the Samsung Wireless Audio Integration
Contribute
- Find a bug or something to improve? Please file a issue at https://github.com/Strixx76/pywam/issues
- Want to contribute with code? Check the source at https://github.com/Strixx76/pywam
Roadmap
- There are some TODO's in the source that should be fixed.
- Better workaround for play_url to show correct state when url streams are played.
- I would also like to change all the API keys and values strings in both the event receiver and the state machine to string enums.
- Make the code less complex.
- Add more API calls.
Style guide
PEP8 and Google styled PEP257. But none of them is strictly enforced.
License
The project is licensed under the MIT License.
Disclaimer Notice
I have tested all functions in this library on all of my Samsung Multiroom speakers, and the worst that has happened is that speakers froze when receiving faulty calls. A simple power cycle would solve it. But I CAN’T guarantee that your speaker is compatible with this library, and you can’t hold me responsible if you brick your speaker when using this library.
Versioning and Changelog
This project uses Semantic Versioning. The changelog format is based on Keep a Changelog
Credits
This project would not have been possible without, but not limited to, the following projects:
- Samsung Wireless Audio Multiroom (WAM) Research, Moosy Research
- WAM_API_DOC, Bruno Lopes
- com.samsung.wam, Bjørnar Almli
- Hubitat-Samsung-WiFi-Audio, David Gutheinz
- Samsung Multiroom (WIP), Krystian Galutowski
- SamsungNotify, Moengiant
Support the work
If you find this library useful please consider a small donation to show your appreciation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywam-0.2.0.tar.gz.
File metadata
- Download URL: pywam-0.2.0.tar.gz
- Upload date:
- Size: 47.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3520f1a7c376cb2da2df2eab9abef8690334909874b175ad9cc8e3c261ffc0ba
|
|
| MD5 |
77700977edb9591bad3d1e103e7790e7
|
|
| BLAKE2b-256 |
285471ea541135a76341b2da98fabdc4f8bdc7e311ded5884a00a57ce7f3656c
|
Provenance
The following attestation bundles were made for pywam-0.2.0.tar.gz:
Publisher:
publish.yml on Strixx76/pywam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywam-0.2.0.tar.gz -
Subject digest:
3520f1a7c376cb2da2df2eab9abef8690334909874b175ad9cc8e3c261ffc0ba - Sigstore transparency entry: 956465395
- Sigstore integration time:
-
Permalink:
Strixx76/pywam@df65e4dcc4468d13c0d0d2658baf0580b885d837 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Strixx76
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@df65e4dcc4468d13c0d0d2658baf0580b885d837 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pywam-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pywam-0.2.0-py3-none-any.whl
- Upload date:
- Size: 51.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20ef5914abe65c99725f0d6243fe6cabcf89db7b91cef17039647b5d6ae46d11
|
|
| MD5 |
10ae1ed1a238704de6c63f620857c3bb
|
|
| BLAKE2b-256 |
9ed841af2a6ac74a083850b1ae6fb3d4a62b846c75407722d0022bb52f637989
|
Provenance
The following attestation bundles were made for pywam-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Strixx76/pywam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywam-0.2.0-py3-none-any.whl -
Subject digest:
20ef5914abe65c99725f0d6243fe6cabcf89db7b91cef17039647b5d6ae46d11 - Sigstore transparency entry: 956465411
- Sigstore integration time:
-
Permalink:
Strixx76/pywam@df65e4dcc4468d13c0d0d2658baf0580b885d837 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Strixx76
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@df65e4dcc4468d13c0d0d2658baf0580b885d837 -
Trigger Event:
workflow_dispatch
-
Statement type: