Code Monkey home page Code Monkey logo

mpr-6zhmaut-api's Introduction

mpr-6zhmaut-api

โš ๏ธ I no longer use this software, instead using remserial and the official Home Assistant integration for the same device.

Monoprice sells this wacky 6 zone amp with a serial interface. This tiny project wraps the serial interface with a JSON API.

A detailed walk-through is available illustrating the process to use this API easily on a Raspberry Pi

Installation

npm install

Environment Variables

DEVICE = <string> - the serial port device name (defaults to /dev/ttyUSB0)

BAUDRATE = <integer> - the baud rate to use to connect to the device (defaults to 9600)

PORT = <integer> - port for API to listen on (defaults to 8181)

AMPCOUNT = <1|2|3> - the number of amps (you can slave up to two additional amps) (defaults to 1)

REQUERY = <true|false> - re-query the keypads before responding to a /zones request (defaults to false)

CORS = <true|false> - respond to a CORS request with an Access-Control-Allow-Origin=* (defaults to false)

Running the server

PORT=8181 npm start

or using more environment variables:

PORT=8181 AMPCOUNT=2 REQUERY=false BAUDRATE=115200 CORS=false npm start

Updating the Baud Rate

You can update the baud rate of the controller to one of the following rates: 9600, 19200, 38400, 57600, 115200, 230400

By default, at power loss, the device is set to run at 9600 BAUD. You can adjust it using the updateBaudRate.js via npm run-script (or directly with node).

OLDBAUDRATE=9600 NEWBAUDRATE=115200 npm run-script baudrate

Notes:

  • To reset the baud rate remove power from the controller for 30 seconds - it will reset to 9600 BAUD
  • Running npm run-script baudrate with the incorrect connection baud rate will not cause it to lock so intialization scripting could be created to reset the baudrate before the API enables.

Environment Variables for updateBaudRate.js

DEVICE = <string> - the serial port device name (defaults to /dev/ttyUSB0)

OLDBAUDRATE = <integer> - the current baud rate of the controller (the rate used to initially connect to the device)

NEWBAUDRATE = <integer> - the desired baud rate

API

GET /zones

[
  {
    "zone": "11",
    "pa": "00",
    "pr": "01",
    "mu": "00",
    "dt": "00",
    "vo": "15",
    "tr": "10",
    "bs": "10",
    "bl": "10",
    "ch": "01",
    "ls": "00"
  },
  {
    "zone": "12",
    "pa": "00",
    "pr": "01",
    "mu": "00",
    "dt": "00",
    "vo": "15",
    "tr": "10",
    "bs": "10",
    "bl": "10",
    "ch": "01",
    "ls": "00"
  },
  {
    "zone": "13",
    "pa": "00",
    "pr": "01",
    "mu": "00",
    "dt": "00",
    "vo": "15",
    "tr": "10",
    "bs": "10",
    "bl": "10",
    "ch": "01",
    "ls": "00"
  },
  {
    "zone": "14",
    "pa": "00",
    "pr": "01",
    "mu": "00",
    "dt": "00",
    "vo": "10",
    "tr": "10",
    "bs": "12",
    "bl": "10",
    "ch": "02",
    "ls": "00"
  },
  {
    "zone": "15",
    "pa": "00",
    "pr": "01",
    "mu": "00",
    "dt": "00",
    "vo": "20",
    "tr": "07",
    "bs": "07",
    "bl": "10",
    "ch": "01",
    "ls": "00"
  },
  {
    "zone": "16",
    "pa": "00",
    "pr": "01",
    "mu": "00",
    "dt": "00",
    "vo": "21",
    "tr": "07",
    "bs": "07",
    "bl": "10",
    "ch": "01",
    "ls": "00"
  }
]

GET /zones/:zone

Returns the current status of a specific zone.

{
  "zone": "11",
  "pa": "00",
  "pr": "01",
  "mu": "00",
  "dt": "00",
  "vo": "15",
  "tr": "10",
  "bs": "10",
  "bl": "10",
  "ch": "01",
  "ls": "00"
}

GET /zones/:zone/:attribute

Return the value of a specific attribute in a zone as plain text. Valid attributes are:

pa (send zone 1 to all outputs)
power / pr
mute / mu
do not disturb / dt
volume / vo
treble / tr
bass / bs
balance / bl
channel / source / ch
keypad status / ls

$ curl 192.168.1.254:8181/zones/11/bass
10

POST /zones/:zone/:attribute

Update a zone's attribute using the plain-text value of the body.

pa (send zone 1 to all outputs)
power / pr
mute / mu
do not disturb / dt
volume / vo
treble / tr
bass / bs
balance / bl
channel / source / ch

Here's an example where we turn the bass of zone 11 up:

$ curl 192.168.1.254:8181/zones/11
{"zone":"11","pa":"00","pr":"01","mu":"00","dt":"00","vo":"15","tr":"10","bs":"10","bl":"10","ch":"01","ls":"00"}
$ curl -X POST -d '12' 192.168.1.254:8181/zones/11/bass
{"zone":"11","pa":"00","pr":"01","mu":"00","dt":"00","vo":"15","tr":"10","bs":"12","bl":"10","ch":"01","ls":"00"}

Device Manual

The manual for the 6 zone amp is available (via Monoprice)[https://downloads.monoprice.com/files/manuals/10761_Manual_141028.pdf]

Contributions

  • fork
  • create a feature branch
  • open a Pull Request

mpr-6zhmaut-api's People

Contributors

cbschuld avatar citywok avatar jnewland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mpr-6zhmaut-api's Issues

Receive UnhandledPromiseRejectionWarning when attempting `npm start`

Hi there, just a few issues:

  • After I npm install and run PORT=8181 npm start, I receive this error. I tried adding .catch() methods onto async.until(). Can you help me understand what I need to resolve in order to run server? (see output below)

  • Additionally, what would be the best method code-wise to attempt to increase volume? Is this as simple as utilizing the POST method and passing along zone, attribute and new attribute value (attached to req.body as {"vo": "16"}?).

(node:5060) UnhandledPromiseRejectionWarning: Error: Error: No such file or directory, cannot open /dev/ttyUSB0
(node:5060) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5060) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Adding support for GlobalCache itach flex network serial port

Just providing a heads up that I'm starting work on providing support for the iTach Flex network serial port. I know I could replace it with a raspberry pi easier, but that would break the existing app my family has on their phones to control it (we don't even have the keypads installed).

Since the new model has a built in ethernet jack (that appears to be serial to TCP) this will also open the possibility to supporting them in the future (although tests of the free app shows that it's not the same protocol directly)

Update serialport to latest

Update the serialport dependency to current to bypass some of the issues with the older release.

WARNING: the API is different

Multiple amps cause odd return when querying nonexistent

in my case I have two amps in series: master & slave 1

when querying a non-existent amp (>30\r) I receive a set of odd bytes on the receive line that are intermixed into the payload from the previous commands for amp one and amp two

I believe the fix is to environmentally set what your amp count is and react to that by not querying non existent amps. Related, the error never happens on the first amp, ONLY the second amp. I re-wired my amps by swapping their roles and the error maintained. As soon as I stopped querying amp 3 it worked great.

Also, I removed amp number two and left the code unchanged and it worked great. It only appears to be an issue on a two amp system when querying for three.

I'll submit a PR to deal with this.

@jnewland - great work on this; I love the encapsulation in node, makes it so easy to deal with on the PI

Excellent!

I have not tried your code but I am so happy you did this. I just bought two of these amps and was wondering if I was stuck with the wall interfaces or whether I could control them with my phone. This is the piece I was missing.

Two questions:

  1. what kind of wire did you get? I am assuming a usb to serial, but did you have to create your own or is there an off-the-shelf?
  2. If I have two amps set up in a master/slave config, do I need to connect to both serial ports or just the master?

Thanks!

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.