Skip to main content

Library built on AsyncIO for communicating with Samsung Wireless Audio speakers (WAM).

Project description

pywam

License PyPi Downloads

Buy Me A Coffee Ko-fi Paypal GitHub Sponsors

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

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:

Support the work

If you find this library useful please consider a small donation to show your appreciation.

Buy Me A Coffee Ko-fi Paypal GitHub Sponsors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywam-0.2.0.tar.gz (47.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywam-0.2.0-py3-none-any.whl (51.5 kB view details)

Uploaded Python 3

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

Hashes for pywam-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3520f1a7c376cb2da2df2eab9abef8690334909874b175ad9cc8e3c261ffc0ba
MD5 77700977edb9591bad3d1e103e7790e7
BLAKE2b-256 285471ea541135a76341b2da98fabdc4f8bdc7e311ded5884a00a57ce7f3656c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywam-0.2.0.tar.gz:

Publisher: publish.yml on Strixx76/pywam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pywam-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20ef5914abe65c99725f0d6243fe6cabcf89db7b91cef17039647b5d6ae46d11
MD5 10ae1ed1a238704de6c63f620857c3bb
BLAKE2b-256 9ed841af2a6ac74a083850b1ae6fb3d4a62b846c75407722d0022bb52f637989

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywam-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Strixx76/pywam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page