Turn on a LED when Volumio UI is ready

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”.

[code]volumio@volumio:~$ wget localhost/playback
converted ‘http://localhost/playback’ (ANSI_X3.4-1968) -> ‘http://localhost/playback’ (UTF-8)
–2017-01-29 15:57:27-- http://localhost/playback
Resolving localhost (localhost)… 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:80… failed: Connection refused.
Connecting to localhost (localhost)|::1|:80… failed: Cannot assign requested address.
Retrying.

[i]–2017-01-29 15:57:28-- (try: 2) http://localhost/playback
Connecting to localhost (localhost)|127.0.0.1|:80… failed: Connection refused.
Connecting to localhost (localhost)|::1|:80… failed: Cannot assign requested address.
Retrying.

–2017-01-29 15:57:30-- (try: 3) http://localhost/playback
Connecting to localhost (localhost)|127.0.0.1|:80… failed: Connection refused.
Connecting to localhost (localhost)|::1|:80… failed: Cannot assign requested address.
Retrying.[/i][/code]

Could you please suggest alternative ways to achieve the result?

Thanks a lot!
Antonio

You cannot connect to localhost trough port 80, volumio have a iptables rule to redirect traffic from 80 to 3000, try to port 3000

Regards

Ok, port 3000 works!
Thanks a lot!

Antonio

Hi antac,

would that be possible to get your script? I would like also to have a led on when UI is ready!

Thanks a lot!

meaz

Did you get this working? I would love to see a full writeup on how you got it done because I’m wanting to do the same thing.

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()

Thanks for the script :smiley: but, how to put it in autostart :question:

Does not anyone have an idea? :cry:

quick tutorial instructables.com/id/Raspber … n-startup/

Ok i can run this script from terminal, but when i try add it to cron it is not running.
It need be run as root, so need password

I try start script from systemd but it not start with error 111 python connection refused.

Strange, because when i start by hand everything work ok.

Can you tell me how you run it on startup?

Anyone?

@mredone

Hi,

Try this:

sudo nano /etc/rc.local

and add the next line before the line with ‘exit 0’

(/home/volumio/guiready.py)&

script.png
save and close the file with: Ctrl+x, and Y

By the way, make sure your python script is executable:

sudo chmod +x guiready.py

script2.png
Kind regards

Harry

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.

Sorry for my english

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).

Ok. I check gpio buttons how it works and i try create new plugin for GUI ready led.

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.

I use thing like https://lowpowerlab.com/guide/atxraspi/
It use script when i click phisical button it send to RPI shutdown command.

I check your plugin and maybe i add support to GUI ready gpio.

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.

Hello ,
does not work with the new Volumio 2.599 anymore. want the plugin for my on / off status led. Hope you can fix it. Thank you