Hi, I would like to turn on a LED when Volumio web UI is ready, via a GPIO pin (Raspberry pi B+ with HifiBerry DAC+ pro).
I’ve tryed to create a bash script (running it like a daemon) that use wget command to access the /playback main page, but I get “connection refused”.
You should be able to use a python script (after install wget with pip)
like this:
#!/usr/bin/python
#
##########################################
# Run like this: sudo python guiready.py #
##########################################
import RPi.GPIO as GPIO
import wget
import time
## Define variables
url = 'http://localhost:3000/index.html'
filename = wget.download(url, out='/home/volumio/', bar=None)
LEDpin = 37 ## pin 37 on the interface goes to + of LED
## ground site (-) of LED connect to pin 39
def setup():
GPIO.setmode(GPIO.BOARD) ## Numbers GPIOs by actual pin numbers
GPIO.setup(LEDpin,GPIO.OUT) ## Set LEDpin as output mode
def LEDon():
while True:
if filename: ## Get a file from the URL
break
else:
time.sleep(2)
GPIO.output(LEDpin, GPIO.HIGH) ## LED on
def destroy():
GPIO.output(LEDpin, GPIO.LOW) ## LED off
GPIO.cleanup() ## Release resource
if __name__ == '__main__': ## Program start from here
setup()
try:
LEDon()
except KeyboardInterrupt: ## When 'CTRL+C' is pressed.
destroy()
So i try rc.local and same thing.
Problem with rc.local is rc.local not have a recovery from error, and rc.local scripts is killed by next system process.
Script check site and led on is wait in loop so if it not download with wget it wait. But is killed by next system process and not check long enough.
An other way to do what you want would be to write a plugin using the lib onoff. Easy to install and share!
Have a look at other plugins using this link (gpio, rotary encoder, and other).
I have something nearly ready for that :[urlhttps://github.com/balbuze/volumio-plugins/tree/master/plugins/system_controller/volsmartpower[/url]. The boot ok signal is the output for a del. Let me know.
Hehehe we had the same idea, I named mine after the soundcard I’m using it with: Audiophonics, the code was neatly created by Jedail in combination with an node implementation for the LCD.