Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
TheD6Bel wrote: Hello RobbeD your script work perfectly! i change ip 127.0.0.1 to my nas ip (lms run on my synology) and and change GPIO.output(18, True) to GPIO.output(18, False) and GPIO.output(18, False) to GPIO.output(18, True) for work with my relay. Thanks ;) That's very good news! :-) The reason that I changed the relay pinouts is that the relay is automatically switched off when there is no connection to the server, or if the raspberry is switched off. RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
That's weird, I don't have those problems here.. Are you using the web user interface or another controller? You can run the script and check the output.. Maybe it has something to do with LMS settings? RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
Hi! That's strange, I thought the script would run without problems.. I am thinking if I did install something extra on the raspberry.. It's also weird that the script doesn't understand the import command.. I run the script like this: python relay.py Can you try that? RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
Hey guys, I recently changed the script so it now works with the XPL plugin.. This makes the script more smooth and lightweight! It also now reacts instant! :-) To make the script run you'll need to install the xPL plugin in LMS. After that you just change the name of the player in the script and it should work! :-) 16697 +---+ |Filename: relayscript.py.txt | |Download: http://forums.slimdevices.com/attachment.php?attachmentid=16697| +---+ RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
[slim] Squeezeplay - Choose Player - Turn off player issue
Hi! I have 2 vintage radio's with raspberry pi's inside running squeezeplug. I also have a joggler with SqueezePlayOS that i use to control these two radio's. So I use the Choose Player function on the joggler a lot. The thing is, when I choose a player in the Choose Player menu, and I want to turn this player off, the joggler goes into some kind of sleep mode and only shows me the X button to turn it on again. But when I press that X button, the player turns on again. Is there a function I'm not aware of to turn off a player without turning off the controller? Now I'm using the web interface to turn all the players off independently, but it would be nice to be able to do this using the Joggler-controller.. Do you guys have any idea? Thanks! Regards, Robbe RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=100982 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
TheD6Bel, that's great news! :-) I have added another piece of code that checks every two seconds if the server is online. If the server is online, then the status of the player is checked, otherwise not. The file is in attachment. 14795 For your problem that the relay is on when LMS is turned off and the opposite, i think you should switch the outgoing wires on your relay.. Good luck, and if you have other questions, post them here! Greetings, Robbe +---+ |Filename: relay.py.txt | |Download: http://forums.slimdevices.com/attachment.php?attachmentid=14795| +---+ RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
Hi, indeed, the python script is indentation-sensitive. For me, the script works the way I copied it here on the forum.. But i'm aware that maybe the lay-out is not that good.. I'll add my script here in attachment.. 14774 I now did the indentation with WING-IDE and it looks correct.. Hope it works now! :-) To Julf: I think you are more experienced with Python than I am, is there a way to make the script use less resources? (now it uses between 3-6% CPU (of a total of 850 Mhz) of the raspberry pi and 1.5% of memory (of a total of 512MB).. Or are there things in the script that are not done? Thanks in advance! Greetings, Robbe +---+ |Filename: relay.py.txt | |Download: http://forums.slimdevices.com/attachment.php?attachmentid=14774| +---+ RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
Hi, I'll tell you what I did to make it work: I saved the script as relay.py and ran it just with python relay.py (as root). Later I made a service script in etc\init.d to run it at boot.. Maybe you should try to add :9000 behind the ip adress of your server? Maybe that can be the problem. My relay is connected as follows: VCC pin 2, GND pin 6, CTRL pin 12.. RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
Hello, Sorry for bumping this thread, but for people who are still searching for an easy script to trigger a relay i've created a python script that runs at boot. The script checks the powerstate of the player every second (script runs on a raspberry pi where squeezelite is installed), and if powerstate = 1 then relay is turned on, otherwise the relay is turned off. It works perfectly. The only thing you need to enter is the mac-adress of your player and the adress of your server (ip adress or url). For the start up process i let the script wait 5 minutes before it gets executed, because if the player and the server are on the same machine, and the machine is rebooted, it takes a while to start lms. If there are things that can be changed in order to make the script better (I'm sure that will be easy, this was my first python script) , feel free to do so and post your changes please! :-) Code: import sys import httplib import RPi.GPIO as GPIO import time time.sleep (300) if float(sys.version[:3]) = 2.6: import json else: # python 2.4 or 2.5 can also import simplejson # as working alternative to the json included. import simplejson as json # change to your server server = yourserverip playermac = your player mac adresse # This provides http 1.1 keep alive so preventing DNS lookup # For each request. while True: conn = httplib.HTTPConnection(server) #Make a python dictionary for the request. data = { id: 1, method: slim.request, params: [ , [ player, count, ? ] ] } # So now we convert the dictionary data to a string params = json.dumps(data, sort_keys=True, indent=4) # Make the keep alive request conn.request(POST, /jsonrpc.js, params) httpResponse = conn.getresponse() #print httpResponse.status=%s, httpResponse.reason=%s % (httpResponse.status, httpResponse.reason) data = httpResponse.read() # Load the JSON string back to python dictionary responce = json.loads(data) # print the python dictionary as a JSON string. # print json.dumps(responce, sort_keys=True, indent=4) # Extract the number of players from the python dictionary numberplayers = responce['result'][_count] # print numberplayers=%s % numberplayers playerIdentifiers = [] playerdetected = for i in range(numberplayers): data = { id:1, method:slim.request, params:[ , [player,id,i,?] ] } params = json.dumps(data, sort_keys=True, indent=4) #print params conn.request(POST, /jsonrpc.js, params) httpResponse = conn.getresponse() # print httpResponse.status=%s, httpResponse.reason=%s % (httpResponse.status, httpResponse.reason) data = httpResponse.read() #print data responce = json.loads(data) playerId = responce['result'][_id] #print playerId #print id=%s % playerId #print playermac if (playerId == playermac): playerdetected = playerId if playerdetected : # print playerdetected data = { id:1, method:slim.request, params:[playerdetected, [power,?] ] } params = json.dumps(data, sort_keys=True, indent=4) # print params conn.request(POST, /jsonrpc.js, params) httpResponse = conn.getresponse() # print httpResponse.status=%s, httpResponse.reason=%s % (httpResponse.status, httpResponse.reason) data = httpResponse.read() # print data responce = json.loads(data) powerstate = responce['result'][_power] if powerstate == 1: # print player: + playerdetected + power state: + powerstate GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(18, GPIO.OUT) GPIO.output(18, True) else: powerstate = 0 # print player: + playerdetected + power state: + powerstate GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(18, GPIO.OUT) GPIO.output(18, False) time.sleep (1)
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
Ok! :-) Let me know if it works or not.. RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
Hi, Could someone help me to modify the Power Switch plugin to control the gpio pins on the raspberry pi? I think this could be easier than using an USB-relay.. How do I start with this? I have no experience with squeezebox plugins.. Thanks in advance! RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss
Re: [slim] Squeezebox Server with Squeezeslave to turn on speakers when playing
Hi! I know your post is almost three years old, but you never know.. I also would like to use a relay for this purpose! My idea is to let a script run in the background that checks the powerstate of the player (squeezeplay) on the server via CLI. If the powerstate of the player is on, the relax should turn on the amplifier, otherwise it should turn it off. I am building a raspberry pi with squeezeplay into an old radio. Because i am using a raspberry-pi, i need to use an USB relay. I am very interested in your schematics and the program to control the relay. Thanks in advance! Greetings, Robbe RobbeD's Profile: http://forums.slimdevices.com/member.php?userid=56967 View this thread: http://forums.slimdevices.com/showthread.php?t=71077 ___ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/discuss