Python API for talking to Monoprice 6-zone amplifier
Project description
Status
pymonoprice
Python3 interface implementation for Monoprice 6 zone amplifier
Notes
This is for use with Home-Assistant
The full RS-232 serial protocol is documented in docs/rs232-protocol.md.
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 Announcement 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 its 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():
monoprice = await get_async_monoprice('/dev/ttyUSB0')
zone_status = await monoprice.zone_status(11)
if zone_status.power:
await monoprice.set_power(zone_status.zone, False)
asyncio.run(main())
Testing PRs
Every pull request automatically publishes a test build as a GitHub pre-release. You can find the install command in the PR comment posted by the bot, or on the Releases page (pre-releases are tagged pr-{number}).
pip:
pip install https://github.com/OnFreund/pymonoprice/releases/download/pr-42/pymonoprice-0.0.0.dev42-py3-none-any.whl
Home Assistant — temporarily update your integration's manifest.json to use the PEP 508 URL form so HA doesn't overwrite it on restart:
{
"requirements": ["pymonoprice @ https://github.com/OnFreund/pymonoprice/releases/download/pr-42/pymonoprice-0.0.0.dev42-py3-none-any.whl"]
}
Replace 42 with the actual PR number. Revert to the pinned version (e.g. pymonoprice==0.6) after testing.
The install URL is stable for the lifetime of the PR — new commits to the same PR reuse the same tag and wheel name, so you don't need to update manifest.json if more commits are pushed.
The pre-release and comment are deleted automatically when the PR is merged or closed.
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
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 pymonoprice-0.6.tar.gz.
File metadata
- Download URL: pymonoprice-0.6.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ce8e8c279bef7b3351d6891e8bafc20e0e6a8120a169403300e926f1510285a
|
|
| MD5 |
8440a545d35af4f4e86603b8f631662c
|
|
| BLAKE2b-256 |
c3f915a9b6654ea5d72f25cb4cc837ae4fba216e6a9152f967533c89f48207b2
|
Provenance
The following attestation bundles were made for pymonoprice-0.6.tar.gz:
Publisher:
release.yml on OnFreund/pymonoprice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymonoprice-0.6.tar.gz -
Subject digest:
7ce8e8c279bef7b3351d6891e8bafc20e0e6a8120a169403300e926f1510285a - Sigstore transparency entry: 1978041421
- Sigstore integration time:
-
Permalink:
OnFreund/pymonoprice@91607ebcbe8665fe0c37e4e4a28e4d9440dd5183 -
Branch / Tag:
refs/tags/v0.6 - Owner: https://github.com/OnFreund
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91607ebcbe8665fe0c37e4e4a28e4d9440dd5183 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pymonoprice-0.6-py3-none-any.whl.
File metadata
- Download URL: pymonoprice-0.6-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
775d7d30db3f3214b3d025f08f18378ed31dcb22ed42f681a262a805169eccd8
|
|
| MD5 |
5478c99a20ba632a50933685df121a2b
|
|
| BLAKE2b-256 |
7cb2ffd89665e0a75f54fba8a2a0a62198652b48b667d774309c91efd0cc8730
|
Provenance
The following attestation bundles were made for pymonoprice-0.6-py3-none-any.whl:
Publisher:
release.yml on OnFreund/pymonoprice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymonoprice-0.6-py3-none-any.whl -
Subject digest:
775d7d30db3f3214b3d025f08f18378ed31dcb22ed42f681a262a805169eccd8 - Sigstore transparency entry: 1978041486
- Sigstore integration time:
-
Permalink:
OnFreund/pymonoprice@91607ebcbe8665fe0c37e4e4a28e4d9440dd5183 -
Branch / Tag:
refs/tags/v0.6 - Owner: https://github.com/OnFreund
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91607ebcbe8665fe0c37e4e4a28e4d9440dd5183 -
Trigger Event:
release
-
Statement type: