Repository: miczflor/rpi-jukebox-rfid
Issue: 🐛 | GPIO Buttons do not work (python script error)

## Bug
GPIO Buttons do not work (python script error)

### What I did
hardware is a raspberry pi 3 with a hifiberry amp and a rc522, using 223B touch buttons for gpio input.
everything works except the gpio-buttons

### What happened

installed the gpio-buttons 
i get the following erros when i start the daemon

```
pi@raspberrypi:~/RPi-Jukebox-RFID/components/gpio_control $ ./gpio_control.py 
INFO:root:['VolumeControl', 'PrevNextControl', 'PlayPause', 'Shutdown', 'Volume0', 'VolumeUp', 'VolumeDown', 'NextSong', 'PrevSong', 'Halt']
INFO:root:adding GPIO-Device, VolumeControl
VolumeControl
INFO:gpio_control:VolumeControl as TwoButtonControl
INFO:GPIODevices.two_button_control:adding new action
INFO:GPIODevices.simple_button:{}: set when_pressed
INFO:GPIODevices.simple_button:add new action
INFO:GPIODevices.simple_button:{}: set when_pressed
INFO:GPIODevices.simple_button:add new action
INFO:root:adding GPIO-Device, PrevNextControl
PrevNextControl
INFO:root:adding TwoButtonControl
INFO:GPIODevices.two_button_control:adding new action
INFO:GPIODevices.simple_button:{}: set when_pressed
INFO:GPIODevices.simple_button:add new action
INFO:GPIODevices.simple_button:{}: set when_pressed
INFO:GPIODevices.simple_button:add new action
INFO:root:adding GPIO-Device, PlayPause
PlayPause
Traceback (most recent call last):
  File "./gpio_control.py", line 105, in <module>
    devices = get_all_devices(config)
  File "./gpio_control.py", line 83, in get_all_devices
    device = generate_device(config[section], section)
  File "./gpio_control.py", line 54, in generate_device
    pull_up_down=config.get('pull_up_down', fallback='GPIO.PUD_UP'))
  File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/GPIODevices/simple_button.py", line 66, in __init__
    self.pull_up_down = parse_pull_up_down(pull_up_down)
  File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/GPIODevices/simple_button.py", line 34, in parse_pull_up_down
    raise KeyError('Unknown Pull Up/Down type {pull_up_down}'.format(pull_up_down=pull_up_down))
KeyError: 'Unknown Pull Up/Down type GPIO.PUD_UP'
Exception ignored in: <function SimpleButton.__del__ at 0x765ca3d8>
Traceback (most recent call last):
  File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/GPIODevices/simple_button.py", line 110, in __del__
    GPIO.remove_event_detect(self.pin)
AttributeError: 'SimpleButton' object has no attribute 'pin'
```

```
[DEFAULT]
enabled: True
[VolumeControl]
enabled: True
Type: TwoButtonControl ;or RotaryEncoder
PinUp: 5
PinDown: 6
pull_up: True
hold_time: 0.3
hold_repeat: True
timeBase: 0.1 ;only for RotaryEncoder
functionCallDown: functionCallVolD
functionCallUp: functionCallVolU
functionCallTwoButtons: functionCallVol0 ;only for TwoButtonControl

[PrevNextControl]
enabled: True
Type: TwoButtonControl
Pin1: 22
Pin2: 23
functionCall1: functionCallPlayerPrev
functionCall2: functionCallPlayerNext
functionCallTwoButtons: None
pull_up: True
hold_time: 0.3
hold_repeat: False

[PlayPause]
enabled: True
Type: Button
Pin: 27
pull_up: True
hold_time: 0.3
functionCall: functionCallPlayerPause

[Shutdown]
enabled: False
Type:  Button
Pin: 3
pull_up: True
hold_time: 2
functionCall: functionCallShutdown

[Volume0]
enabled: False
Type:  Button
Pin: 17
pull_up: True
hold_time: 0.3
functionCall: functionCallVol0

[VolumeUp]
enabled: False
Type:  Button
Pin: 16
pull_up: True
hold_time: 0.3
hold_repeat: True
functionCall: functionCallVolU

[VolumeDown]
enabled: False
Type:  Button
Pin: 19
pull_up: True
hold_time: 0.3
hold_repeat: True
functionCall: functionCallVolD


[NextSong]
enabled: False
Type:  Button
Pin: 26
pull_up: True
hold_time: 0.3
functionCall: functionCallPlayerNext

[PrevSong]
enabled: False
Type:  Button
Pin: 20
pull_up: True
hold_time: 0.3
functionCall: functionCallPlayerPrev

[Halt]
enabled: False
Type:  Button
Pin: 21
pull_up: True
hold_time: 0.3
functionCall: functionCallPlayerPauseForce

```

### Further information that might help

tested the functionality with simple_button.py and it worked

pi@raspberrypi:~/RPi-Jukebox-RFID/components/gpio_control/GPIODevices $ python simple_button.py 
please enter pin no to test
27
FunctionCall with (27,)
FunctionCall with (27,)
FunctionCall with (27,)
FunctionCall with (27,)
FunctionCall with (27,)


## Software

### Base image and version

pi@raspberrypi:~/RPi-Jukebox-RFID/components/gpio_control/GPIODevices $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

### Branch / Release

pi@raspberrypi:~/RPi-Jukebox-RFID/components/gpio_control/GPIODevices $ cd /home/pi/RPi-Jukebox-RFID/ && git status | head -2
Refresh index: 100% (390/390), done.
On branch develop
Your branch is up to date with 'origin/develop'.

### Installscript

i.e. `scripts/installscripts/buster-install-default.sh`
without spotify support

## Hardware

### RaspberryPi version

Raspberry Pi 3 Model B Rev 1.2

### RFID Reader

RC522

### Soundcard

Hifi Berry Amp

### Other notable hardware

default settings imported to /home/pi/.config/phoniebox/gpio-settings.ini


Changed files:
components/gpio_control/gpio_control.py

diff --git a/components/gpio_control/gpio_control.py b/components/gpio_control/gpio_control.py
index 2a838379..6bb958ed 100755
--- a/components/gpio_control/gpio_control.py
+++ b/components/gpio_control/gpio_control.py
@@ -51,7 +51,7 @@ def generate_device(config, deviceName):
                             edge=config.get('edge', fallback='FALLING'),
                             hold_repeat=config.getboolean('hold_repeat', False),
                             hold_time=config.getfloat('hold_time', fallback=0.3),
-                            pull_up_down=config.get('pull_up_down', fallback='GPIO.PUD_UP'))
+                            pull_up_down=config.get('pull_up_down', fallback=GPIO.PUD_UP))
     elif device_type == 'LED':
         return LED(config.getint('Pin'),
                             name=deviceName,