Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


moOde 5.0 Release Candidate RC1
#31
(04-03-2019, 08:43 PM)imi11 Wrote: Could you explain the "debug print" (after entering second sudo command)...

Sure. See the actual script below. When its run from the cmd line it prints the configuration for each button thats ON.

Code:
#!/usr/bin/python
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License version 2 as
#   published by the Free Software Foundation.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
#    Based on the script posted in moOde Forum by @Cyanoazimin
#    2019-MM-DD TC moOde 5.0
#

import RPi.GPIO as GPIO
import sys
import time
import datetime
import os
import subprocess
import sqlite3

# Set GPIO pin numbering mode
GPIO.setmode(GPIO.BCM)

# get the configuration
db = sqlite3.connect('/var/local/www/db/moode-sqlite3.db')
db.row_factory = sqlite3.Row
db.text_factory = str
cursor = db.cursor()

# get bounce_time
cursor.execute("SELECT value FROM cfg_gpio WHERE param='bounce_time'")
row = cursor.fetchone()
bounce_time = int(row['value'])
#print str(datetime.datetime.now())[:19] + ' bounce_time=' + str(bounce_time)

# configure the pins
cursor.execute("SELECT * FROM cfg_gpio")
for row in cursor:    
    #print str(datetime.datetime.now())[:19] + ' row id=' + str(row['id']) + ', enabled=' + row['enabled'] + ', command=' + row['command']
    if str(row['id']) == '1' and row['enabled'] == '1':
        sw_1_pin = int(row['pin'])
        sw_1_cmd = row['command'].split(' ')
        GPIO.setup(sw_1_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
        def sw_1_event(channel):
            subprocess.call(sw_1_cmd)
        GPIO.add_event_detect(sw_1_pin, GPIO.RISING, callback = sw_1_event, bouncetime = bounce_time)
        print str(datetime.datetime.now())[:19] + ' sw_1: pin=' + str(sw_1_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
    elif str(row['id']) == '2' and row['enabled'] == '1':
        sw_2_pin = int(row['pin'])
        sw_2_cmd = row['command'].split(' ')
        GPIO.setup(sw_2_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
        def sw_2_event(channel):
            subprocess.call(sw_2_cmd)
        GPIO.add_event_detect(sw_2_pin, GPIO.RISING, callback = sw_2_event, bouncetime = bounce_time)
        print str(datetime.datetime.now())[:19] + ' sw_2: pin=' + str(sw_2_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
    elif str(row['id']) == '3' and row['enabled'] == '1':
        sw_3_pin = int(row['pin'])
        sw_3_cmd = row['command'].split(' ')
        GPIO.setup(sw_3_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
        def sw_3_event(channel):
            subprocess.call(sw_3_cmd)
        GPIO.add_event_detect(sw_3_pin, GPIO.RISING, callback = sw_3_event, bouncetime = bounce_time)
        print str(datetime.datetime.now())[:19] + ' sw_3: pin=' + str(sw_3_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
    elif str(row['id']) == '4' and row['enabled'] == '1':
        sw_4_pin = int(row['pin'])
        sw_4_cmd = row['command'].split(' ')
        GPIO.setup(sw_4_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
        def sw_4_event(channel):
            subprocess.call(sw_4_cmd)
        GPIO.add_event_detect(sw_4_pin, GPIO.RISING, callback = sw_4_event, bouncetime = bounce_time)
        print str(datetime.datetime.now())[:19] + ' sw_4: pin=' + str(sw_4_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
    elif str(row['id']) == '5' and row['enabled'] == '1':
        sw_5_pin = int(row['pin'])
        sw_5_cmd = row['command'].split(' ')
        GPIO.setup(sw_5_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
        def sw_5_event(channel):
            subprocess.call(sw_5_cmd)
        GPIO.add_event_detect(sw_5_pin, GPIO.RISING, callback = sw_5_event, bouncetime = bounce_time)
        print str(datetime.datetime.now())[:19] + ' sw_5: pin=' + str(sw_5_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
    elif str(row['id']) == '6' and row['enabled'] == '1':
        sw_6_pin = int(row['pin'])
        sw_6_cmd = row['command'].split(' ')
        GPIO.setup(sw_6_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
        def sw_6_event(channel):
            subprocess.call(sw_6_cmd)
        GPIO.add_event_detect(sw_6_pin, GPIO.RISING, callback = sw_6_event, bouncetime = bounce_time)
        print str(datetime.datetime.now())[:19] + ' sw_6: pin=' + str(sw_6_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
    elif str(row['id']) == '7' and row['enabled'] == '1':
        sw_7_pin = int(row['pin'])
        sw_7_cmd = row['command'].split(' ')
        GPIO.setup(sw_7_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
        def sw_7_event(channel):
            subprocess.call(sw_7_cmd)
        GPIO.add_event_detect(sw_7_pin, GPIO.RISING, callback = sw_7_event, bouncetime = bounce_time)
        print str(datetime.datetime.now())[:19] + ' sw_7: pin=' + str(sw_7_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
    elif str(row['id']) == '8' and row['enabled'] == '1':
        sw_8_pin = int(row['pin'])
        sw_8_cmd = row['command'].split(' ')
        GPIO.setup(sw_8_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
        def sw_8_event(channel):
            subprocess.call(sw_8_cmd)
        GPIO.add_event_detect(sw_8_pin, GPIO.RISING, callback = sw_8_event, bouncetime = bounce_time)
        print str(datetime.datetime.now())[:19] + ' sw_8: pin=' + str(sw_8_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']

# Main
while True:
    time.sleep(1)
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#32
(04-03-2019, 08:47 PM)miklau Wrote:
(04-03-2019, 08:36 PM)Tim Curtis Wrote: Looks ok.

What were the entries on the NAS Source screen?

Host/share
Userid
Password *****
Name

 

I also tried with "Guest" and no password. Stil the same error.

The challenge is that the errors reported by the mount command are almost useless.

I'd suggest trying the mount manually

Code:
mkdir /mnt/NAS/NAS540
sudo mount -t cifs "//NAS540/music" -o username="admin",password="**********",rsize=61440,wsize=65536,iocharset=utf8,vers=1.0,ro,dir_mode=0777,file_mode=0777 "/mnt/NAS/NAS540"

sudo umount /mnt/NAS/NAS540
sudo rmdir /mnt/NAS/NAS540
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#33
Rumor has it that Spotify connect is going away due to changes/upgrades from Spotify.

Have you heard anything along these lines?
Reply
#34
@Edward

Please start a new thread.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#35
(04-03-2019, 08:15 PM)Tim Curtis Wrote: You will need to run the python script from SSH cmd line and post the debug print.

Code:
sudo killall gpio-buttons.py
sudo /var/www/command/gpio-buttons.py

Running these fromm ssh, the button works! Thanks Smile
But after changing gpio button settings I have to run these scripts again from ssh after saving settings. Could you solve to be runned these automaically after saving settings not to have to be runned separatelly from ssh?

Could you help me how could I add folder tracks to be played in alphabetical order?

Thanks for help!
Reply
#36
Thanks for reporting this. There are 2 bugs causing the button handler start/restart to fail. Either email or PM me and I'll provide the patches. They will be included in an in-place update planned for RC1 :-)

You prolly need to write a script to sort a track listing alphabetically by title and then add the tracks to the Playlist but maybe there is an easier way. I'm not really sure.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#37
(04-03-2019, 09:08 PM)Tim Curtis Wrote:
(04-03-2019, 08:47 PM)miklau Wrote:
(04-03-2019, 08:36 PM)Tim Curtis Wrote: Looks ok.

What were the entries on the NAS Source screen?

Host/share
Userid
Password *****
Name

 

I also tried with "Guest" and no password. Stil the same error.

The challenge is that the errors reported by the mount command are almost useless.

I'd suggest trying the mount manually

Code:
mkdir /mnt/NAS/NAS540
sudo mount -t cifs "//NAS540/music" -o username="admin",password="**********",rsize=61440,wsize=65536,iocharset=utf8,vers=1.0,ro,dir_mode=0777,file_mode=0777 "/mnt/NAS/NAS540"

sudo umount /mnt/NAS/NAS540
sudo rmdir /mnt/NAS/NAS540

Thanks Tim

I did try to run the commands but I was still not able to mount my NAS. I have double checked username and password and user authentication at ny NAS settings. everthing should be fine there as well. Here is result form terminal:
Code:
pi@moode:~ $ sudo mount -t cifs "//NAS540/music" -o username="admin",password="*********",rsize=61440,wsize=65536,iocharset=utf8,vers=1.0,ro,dir_mode=0777,file_mode=0777 "/mnt/NAS/NAS540"
mount error: could not resolve address for NAS540: Unknown error
pi@moode:~ $ sudo mount -t cifs "smb://NAS540/music" -o username="admin",password="********",rsize=61440,wsize=65536,iocharset=utf8,vers=1.0,ro,dir_mode=0777,file_mode=0777 "/mnt/NAS/NAS540"
Mounting cifs URL not implemented yet. Attempt to mount smb://NAS540/music
pi@moode:~ $ sudo umount /mnt/NAS/NAS540
umount: /mnt/NAS/NAS540: not mounted

Does that look any diffrent or maybe I ma not doing it right...
Reply
#38
At some point when v5 becomes gold will 4.4 be capable of upgrading to it ? If so i'll just wait till this option becomes available. As upgrading my current setup is not easy, Choosing to run Pi hole on the same Pi has made just flashing v5rc1 not a viable option as when it boots, theres no pi hole running to give it an ip address.
Reply
#39
Wow, thanks for all your work Tim.

I continue to mainly to use Moode as a upnp renderer and I see that upmpdcli v1.4.2 is now available. It’s cheeky to ask, but is there any chance of bumping to this version in the next release candidate, or the final version of 5.0? If I get it right, Moode is still using upmpdcli v1.3.8 and since then various changes have been implemented including fixes to its Spotify and Qobuz capabilities, and apparently there’s now a new media server
Reply
#40
(04-04-2019, 08:50 PM)miklau Wrote:
(04-03-2019, 09:08 PM)Tim Curtis Wrote:
(04-03-2019, 08:47 PM)miklau Wrote:
(04-03-2019, 08:36 PM)Tim Curtis Wrote: Looks ok.

What were the entries on the NAS Source screen?

Host/share
Userid
Password *****
Name

 

I also tried with "Guest" and no password. Stil the same error.

The challenge is that the errors reported by the mount command are almost useless.

I'd suggest trying the mount manually

Code:
mkdir /mnt/NAS/NAS540
sudo mount -t cifs "//NAS540/music" -o username="admin",password="**********",rsize=61440,wsize=65536,iocharset=utf8,vers=1.0,ro,dir_mode=0777,file_mode=0777 "/mnt/NAS/NAS540"

sudo umount /mnt/NAS/NAS540
sudo rmdir /mnt/NAS/NAS540

Thanks Tim

I did try to run the commands but I was still not able to mount my NAS. I have double checked username and password and user authentication at ny NAS settings. everthing should be fine there as well. Here is result form terminal:
Code:
pi@moode:~ $ sudo mount -t cifs "//NAS540/music" -o username="admin",password="*********",rsize=61440,wsize=65536,iocharset=utf8,vers=1.0,ro,dir_mode=0777,file_mode=0777 "/mnt/NAS/NAS540"
mount error: could not resolve address for NAS540: Unknown error
pi@moode:~ $ sudo mount -t cifs "smb://NAS540/music" -o username="admin",password="********",rsize=61440,wsize=65536,iocharset=utf8,vers=1.0,ro,dir_mode=0777,file_mode=0777 "/mnt/NAS/NAS540"
Mounting cifs URL not implemented yet. Attempt to mount smb://NAS540/music
pi@moode:~ $ sudo umount /mnt/NAS/NAS540
umount: /mnt/NAS/NAS540: not mounted

Does that look any diffrent or maybe I ma not doing it right...

@miklau 

Don't use the smb: prefix in this context.

In your first post, you said your SMB server's IP address is 192.168.1.222, so what happens if you try Tim's set of commands but with "//192.168.1.222/music" instead of "NAS540/music"? If that works, then in the moOde NAS Source panel click on the "Edit" link under the Host/Share box and enter "192.168.1.222/music" (without the quotes) manually.

Regards,
Kent
Reply


Forum Jump: