From f638ccbc2eeedd2887fb077ea1c9a4b6a35130e5 Mon Sep 17 00:00:00 2001 From: AxelC Date: Thu, 18 Apr 2019 23:29:13 +0200 Subject: [PATCH] Plug sonos api script, Remove unnecessary readme steps --- README.md | 8 +++----- box.py | 26 +++++++++++++++----------- cardList.csv | 3 +++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7e2b339..f4d2307 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,7 @@ wget http://dl.piwall.co.uk/python-evdev_0.4.1-1_armhf.deb dpkg -i python-evdev_0.4.1-1_armhf.deb ``` -- python mpd-2. To install -```bash -pip install python-mpd2 -``` + ### hardware: - [Raspberry Pi Zero (Don't forget micro sd card and power supply)](http://www.microcenter.com/product/486575/Zero_W) - [USB OTG Hub](https://www.amazon.com/gp/product/B01HYJLZH6/ref=oh_aui_detailpage_o08_s00?ie=UTF8&psc=1) @@ -29,7 +26,8 @@ Please note that Raspberry Pi Zero is insufficient to run both the Home Assistan 1. Run `python config.py` to select the reader from the inputs 2. Run `python add_card.py` to scan cards and enter your Google Play Music Playlist Name -3. Run `python box.py` to start the application and verify that it is reading your cards and csv list properly +3. Make .sh scrypts executables : chmod +x sonosplay.sh +4. Run `python box.py` to start the application and verify that it is reading your cards and csv list properly ## Install Service to AutoStart diff --git a/box.py b/box.py index 6677802..f500fb8 100755 --- a/box.py +++ b/box.py @@ -11,20 +11,24 @@ import time reader = Reader() cardList = CardList() +#TODO Get from config file +addr = 'http://192.168.1.80:5005' + print 'Ready: place a card on top of the reader' while True: - card = reader.readCard() - try: - print 'Read card', card - plist = cardList.getPlaylist(card) - print 'Playlist', plist - if plist != '': - subprocess.check_call( ["./haplaylist.sh %s" % plist], shell=True) + card = reader.readCard() + try: + print 'Read card : ', card + plist = cardList.getPlaylist(card) + print 'Command : ', plist + if plist != '': + subprocess.check_call( ["./sonosplay.sh %s" % addr+' '+plist], shell=True) + # subprocess.check_call( ["./haplaylist.sh %s" % plist], shell=True) range(10000) # some payload code time.sleep(0.2) # sane sleep time of 0.1 seconds - except OSError as e: - print "Execution failed:" - range(10000) # some payload code - time.sleep(0.2) # sane sleep time of 0.1 seconds + except OSError as e: + print "Execution failed:" + range(10000) # some payload code + time.sleep(0.2) # sane sleep time of 0.1 seconds diff --git a/cardList.csv b/cardList.csv index bed19a7..4f1c028 100644 --- a/cardList.csv +++ b/cardList.csv @@ -1 +1,4 @@ 12028599,NameOfGoogleMusicPlaylist +0005690681,playpause +0005597326,next +0013347620,Test3