I picked up a pi zero w to play with, and figured this would be a neat project. I whacked this up this morning and it works pretty good. It's a CLI tool, but it outputs JSON, with the intent of eventually calling it from a web app that would provide connectivity to a phone app and home automation systems. I'm not a web developer, so if someone wants to use this to make a REST web app that will run on the Pi, that would be awesome.
Project is here:
https://github.com/signal15/mp6z
Project is here:
https://github.com/signal15/mp6z
Code:
usage: mp6z.py mode [zone] [-h] [--verbose] [-v V] [-s S] [-b B] [-t T] [-m M] [-d D]
[-p P] [--bl bl]
positional arguments:
mode <get|set>
zone <11-16,21-26,31-36>
optional arguments:
-h, --help show this help message and exit
--verbose Increase output verbosity
-v V Set Volume (0-38)
-s S Set Source (1-6)
-b B Set Bass (0-7)
-t T Set Treble (0-7)
-m M Set Mute (0=Off, 1=On)
-d D Set Do Not Disturb (0=Off, 1=On)
-p P Set Power (0=Off, 1=On)
--bl BL Set Balance (0-20, 10=Center)
Examples:
$ ./mp6z.py get -- This will get the settings for all zones and output in JSON format
$ ./mp6z.py get 21 -- This will get the settings for the 1st zone on the second controller (if you have multiples chained)
$ ./mp6z.py set 21 -v 15 -s 6 -- This will set the 1st zone on the second controller to use source 6 and set volume to 15.
Output will be the new settings in JSON format.
[email protected]:~/mp6z $ ./mp6z.py get 11
{
"11": {
"balance": "10",
"bass": "13",
"dnd": "00",
"keypad": "01",
"mute": "00",
"name": "Dining Room",
"pa": "00",
"power": "01",
"source": "05",
"sourcename": "Empty",
"treble": "14",
"volume": "11"
}
}
[email protected]:~/mp6z $ ./mp6z.py set 21 -v 5 -s 6
{
"21": {
"balance": "10",
"bass": "14",
"dnd": "00",
"keypad": "01",
"mute": "00",
"name": "Office",
"pa": "00",
"power": "01",
"source": "06",
"sourcename": "Sonos",
"treble": "13",
"volume": "05"
}
}