Skip to main content

Python API for talking to Monoprice 6-zone amplifier

Project description

Status

Build StatusCoverage Status

pymonoprice

Python3 interface implementation for Monoprice 6 zone amplifier

Notes

This is for use with Home-Assistant

Usage

from pymonoprice import get_monoprice

monoprice = get_monoprice('/dev/ttyUSB0')
# Valid zones are 11-16 for main monoprice amplifier
zone_status = monoprice.zone_status(11)

# Print zone status
print('Zone Number = {}'.format(zone_status.zone))
print('Power is {}'.format('On' if zone_status.power else 'Off'))
print('Mute is {}'.format('On' if zone_status.mute else 'Off'))
print('Public Anouncement Mode is {}'.format('On' if zone_status.pa else 'Off'))
print('Do Not Disturb Mode is {}'.format('On' if zone_status.do_not_disturb else 'Off'))
print('Volume = {}'.format(zone_status.volume))
print('Treble = {}'.format(zone_status.treble))
print('Bass = {}'.format(zone_status.bass))
print('Balance = {}'.format(zone_status.balance))
print('Source = {}'.format(zone_status.source))
print('Keypad is {}'.format('connected' if zone_status.keypad else 'disconnected'))

# Turn off zone #11
monoprice.set_power(11, False)

# Mute zone #12
monoprice.set_mute(12, True)

# Set volume for zone #13
monoprice.set_volume(13, 15)

# Set source 1 for zone #14 
monoprice.set_source(14, 1)

# Set treble for zone #15
monoprice.set_treble(15, 10)

# Set bass for zone #16
monoprice.set_bass(16, 7)

# Set balance for zone #11
monoprice.set_balance(11, 3)

# Restore zone #11 to it's original state
monoprice.restore_zone(zone_status)

Usage with asyncio

With asyncio flavor all methods of Monoprice object are coroutines.

import asyncio
from pymonoprice import get_async_monoprice

async def main(loop):
    monoprice = await get_async_monoprice('/dev/ttyUSB0', loop)
    zone_status = await monoprice.zone_status(11)
    if zone_status.power:
        await monoprice.set_power(zone_status.zone, False)

loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))

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

pymonoprice-0.5.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

pymonoprice-0.5-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file pymonoprice-0.5.tar.gz.

File metadata

  • Download URL: pymonoprice-0.5.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pymonoprice-0.5.tar.gz
Algorithm Hash digest
SHA256 ab80cec8484993067a9a268859a9c9c2c0550dc1d1834d7f3e0441e2418d522b
MD5 4c3d60812681c53b9bd93f3ee010162a
BLAKE2b-256 2e4486313882a714124c3390b4924b92d5804cc917c12be2ce57cf67a8c3ee09

See more details on using hashes here.

File details

Details for the file pymonoprice-0.5-py3-none-any.whl.

File metadata

  • Download URL: pymonoprice-0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pymonoprice-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ba82485f1fbf212d7328b06cb47554d0e53862ef1510ee2023faf420f941f0fe
MD5 feae79680a298fdbe18ce26afefa2d6a
BLAKE2b-256 ec32bade0464eb8089dacd6f77b6c6d930710cce03fbc7c3616abba2f9308049

See more details on using hashes here.

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