Skip to main content

Python client and CLI for Naim Mu-so 2nd Gen (unofficial).

Project description

pynaim

pynaim is a Python library and CLI tool to control Naim Uniti and Mu-so audio devices via their HTTP API. It provides methods for power control, playback, volume adjustment, source selection, and fetching device information.

The package is tested on an Naim Mu-so 2nd Generation, but should also work on at least some Uniti products. If you run into problems, please let me know.


Features

  • Power control: turn the device on/off
  • Playback control: play, pause, stop, next/previous track, play/pause toggle
  • Volume control: set, increase, decrease, mute, unmute
  • Source selection: choose input source
  • Query device information: diagnostics, favorites, network, now playing, volume levels, power state
  • Asynchronous event stream support for real-time notifications (work in progress)
  • Command-line interface (CLI) for quick control from terminal

Installation

Install via PyPI:

pip install pynaim

Usage in Python

import asyncio
from pynaim import NaimController

controller = NaimController(host="192.168.1.100")
controller.turn_on()
controller.media_play()
controller.volume_up()
print(controller.get_now_playing())

CLI Usage

Once installed, you can use the pynaim CLI:

# Set default host
pynaim set_host --host 192.168.1.100

# Power control
pynaim power on
pynaim power off

# Playback control
pynaim play
pynaim pause
pynaim stop
pynaim playpause
pynaim next
pynaim previous

# Volume control
pynaim volume up
pynaim volume down
pynaim volume mute
pynaim volume unmute
pynaim volume level 25

Use --verbosity flag for more detailed logging.


Event Stream

async def main():
    controller = NaimController(host="192.168.1.100")
    await controller.event_stream()

asyncio.run(main())

⚠️ Event stream implementation is in progress; it handles reconnects but requires improved error handling.


Methods

Power

  • turn_on()
  • turn_off()
  • get_power()

Playback

  • media_play()
  • media_pause()
  • media_stop()
  • media_play_pause()
  • media_next_track()
  • media_previous_track()
  • get_now_playing()
  • get_artist()
  • get_title()
  • get_album()
  • get_artwork()

Volume

  • volume_up()
  • volume_down()
  • volume_set(volume: int)
  • volume_mute()
  • volume_unmute()
  • get_levels()

Inputs / Sources

  • select_source(source_path: str)
  • get_inputs()
  • get_selectable_inputs()

Device Info

  • get_diagnostics()
  • get_favourites()
  • get_network()
  • get_update()

Logging

pynaim uses Python's built-in logging module. Default level is INFO, HTTPX logs are set to WARNING.

import logging
logging.basicConfig(level=logging.INFO)

Notes

  • Some methods use synchronous HTTP requests (httpx.request) for simplicity.
  • Event streaming is asynchronous and requires asyncio.
  • Volume up/down fetches current volume; future updates may cache the value.
  • Source selection does not currently validate against available inputs.
  • CLI stores default host in ~/.config/pynaim/config.json.

License

MIT License

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

pynaim-0.1.2.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

pynaim-0.1.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file pynaim-0.1.2.tar.gz.

File metadata

  • Download URL: pynaim-0.1.2.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pynaim-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9219401b75df4580d0b199c84eec2c8f48ab6e72c2aeccf0d5b94925c0600af4
MD5 658f1a422313cf7e9b045e40c85eb6b0
BLAKE2b-256 2277a3904fb30979039857a6f1a661ea5e8912e285bccf2f9c4afe41857eeff7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynaim-0.1.2.tar.gz:

Publisher: publish.yml on blaauboer/pynaim

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

File details

Details for the file pynaim-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pynaim-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pynaim-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7d05abee26f205b091bf32c94249e8e71e20b0b0227e7d939cd7d30f151e8d5e
MD5 603f6d0106ecea66e56905879c5bae1e
BLAKE2b-256 fad88f51778b597aa25a49644bee2b80577b98045e45deb4f582247a5bf6bc31

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynaim-0.1.2-py3-none-any.whl:

Publisher: publish.yml on blaauboer/pynaim

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