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.1.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.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynaim-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f0006117104fc2f704772ed92c3639c7e595e837a774073b235d8cf1c986974b
MD5 251be03d6ed3c742c2d2f93e3b390925
BLAKE2b-256 e1a613c8d0145dc6d482d841c47cb95527ca1999970c2c7e7d83050fc7ea1d5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynaim-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pynaim-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efa4f88d7ccae8e52a0fdec6539f8b26aa63338ec1843b87b32cf99b56740b31
MD5 3b6245291faf024fd786a52162a75b59
BLAKE2b-256 967f420124bb3d8d7d9e6a94a27d8277c6c9e2c16355043c804610afb3a1b4fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynaim-0.1.1-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