Skip to content

Commit

Permalink
Rewrite readme, add both and for
Browse files Browse the repository at this point in the history
systemd and udev rules respectively.
  • Loading branch information
mrjones-plip committed Jan 14, 2020
1 parent 5026ec2 commit 7a408a0
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 27 deletions.
1 change: 1 addition & 0 deletions 60-powermate.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ACTION=="add", ENV{ID_USB_DRIVER}=="powermate", SYMLINK+="input/powermate", TAG+="uaccess"
73 changes: 46 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A WiFi enabled physical volume knob for Chromecasts via a mash up of Griffin's n
[PowerMate](https://support.griffintechnology.com/product/powermate/) and
the awesome python Chromecast controlling library [catt](https://github.com/skorokithakis/catt/)
using the equally awesome [powermate](https://github.com/bethebunny/powermate)
python library.
python library. You can optionally show the volume on a screen.

Here's the current demo in an animated gif. Behind the PowerMate is a Chromebook running the
Google Home app. When the Cattmate sets the volume you
Expand All @@ -14,57 +14,76 @@ can kinda make out Google Home reflect the volume change as well:

## Status

This project is very much a work in progress. Don't
use unless you're looking to learn and experiment like am right now ;)

Currently it seems pretty stable. You have to manually start it though, and I haven't
tested daemonizing it.
This is my first real Python project! That means while the code is super stable
(my desktop version has an uptime of weeks now), I'm guessing not everything follows the
[Pythonic way](https://docs.python-guide.org/writing/style/) just so.


## Hardware

* Raspbery Pi - I used a [Raspberry Pi Model 3B Rev 1.2](https://amzn.to/2REZXwb)
* [PowerMate](https://support.griffintechnology.com/product/powermate/) - Hopefully you can [find one used on eBay](https://www.ebay.com/sch/i.html?_nkw=griffin+powermate+usb+-bluetooth) if you don't already have one
* [PowerMate](https://support.griffintechnology.com/product/powermate/) - Hopefully you
can [find one used on eBay](https://www.ebay.com/sch/i.html?_nkw=griffin+powermate+usb+-bluetooth) if
you don't already have one
* 0.96" SSD1336 OLED Screen (_optional_) - I use [these from MakerFocus](https://amzn.to/2PKMQqL)
* [Chromecast](https://en.wikipedia.org/wiki/Chromecast) - any sort will do, original, audio or ultra

## Use

Cattmate supports:

* Increase volume - rotate clockwise
* Decrease volume - rotate counter-clockwise
* Mute - push down - the light will strobe to denote muted status
* Unmute - push down again
* Pause - push down and hold 1+ second
* Play - push down and hold 1+ second again
* Fast Forward - push down and rotate clockwise
* Rewind - push down and rotate counter-clockwise

## Install

These steps assume you have your Pi set up with Raspbian, that it's booted up, connected
to the same WiFi as your Chromecast and that the PowerMate is plugged into one of the Pi's
USB ports. If your Chromecast is on a different network, but you can get to it by IP, the
config supports IPs instead of Chromecast names.

1. Make sure the following requirements are installed:
* [pip3](https://pip.pypa.io/en/stable/installing/)
* [virtualenv](https://virtualenv.pypa.io/en/stable/) (_optional_)
1. Clone this repo `git clone https://github.com/Ths2-9Y-LqJt6/cattmate.git`
1. Change directories to cattmate `cd cattmate`
to the same WiFi as your Chromecast. If your Chromecast is on a different network, but
you can get to it by IP, the
config supports IPs instead of Chromecast names. It also assumes you're using the `pi`
default user with a home directory of `/home/pi` and that you have both
[pip3](https://pip.pypa.io/en/stable/installing/) and optionally
[virtualenv](https://virtualenv.pypa.io/en/stable/) installed:

1. Clone this repo and cd into it:
`git clone https://github.com/Ths2-9Y-LqJt6/cattmate.git /home/pi/cattmate; cd /home/pi/cattmate`
1. Create your own virtualenv and activate it `python3 -m venv venv;. venv/bin/activate` (_optional_)
1. Install all the python prerequisites with `pip3 install -r requirements.txt`
1. Create your own config file `cp config.dist.py config.dist` and edit `config.dist` with
the names or IPs
of the chromecasts you want to use (ony first one supported right now ;) and whether you want
to use an external I2C screen or not
1. Start the cattmate controller `python3 cattmate.py`
1. Copy the systemd file into place, reload systemd, start and enable it:
```bash
sudo cp cattmate.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable cattmate
sudo systemctl start cattmate
```
1. Add the ``udev`` rule with ``sudo cp 60-powermate.rules /etc/udev/rules.d/`` and plug your
powermate into an open USB port.

You should be good to go! The system is very resilient in that you can not have screen plugged
in when you start and the plug it in and systemd will notice and start things up. Same
for the powermatte - you can unplug and plug and unplug all day and it satisfyingly just works!

## Use
# Troubleshooting

After getting your hardware and software set up per above, cattmate supports:
* Increase volume - rotate clockwise
* Decrease volume - rotate counter-clockwise
* Mute - push down
* Unmute - push down again
* Pause - push down and hold 1+ second
* Play - push down and hold 1+ second again
* Fast Forward - push down and rotate clockwise
* Rewind - push down and rotate counter-clockwise
You can debug the system in syslog with `sudo tail -f /var/log/syslog`. I try to do a lot
of testing and explicit have `except` errors that expictly tell you what went wrong
and how to fix it. If all else fails, open an issue and I'l try and help ya!
## Releases
* 14 Jan 2020 v0.5 - Rewrite readme, add both `cattmate.service` and `60-powermate.rules` for
systemd and udev rules respectively.
* 16 Dec 2019 v0.13 - Complete refactor to use native python driver
per [#8](https://github.com/Ths2-9Y-LqJt6/cattmate/issues/8) and add pause, ff & rrwnd per
[#10](https://github.com/Ths2-9Y-LqJt6/cattmate/issues/10)
Expand Down
14 changes: 14 additions & 0 deletions cattmate.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=powermate
After=network.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/cattmate
ExecStart=/usr/bin/python3 -u /home/pi/cattmate/cattmate.py
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

0 comments on commit 7a408a0

Please sign in to comment.