GithubHelp home page GithubHelp logo

flacjacket / pymonoprice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from etsinko/pymonoprice

0.0 2.0 0.0 44 KB

Python3 interface implementation for Monoprice 6 zone amplifier

License: MIT License

Python 100.00%

pymonoprice's Introduction

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))

pymonoprice's People

Contributors

etsinko avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.