Skip to content

Commit

Permalink
Improve robustness of powercontroller module
Browse files Browse the repository at this point in the history
  • Loading branch information
hifiberry committed Apr 2, 2024
1 parent 5d30fd8 commit 3cf821f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ac2/plugins/control/powercontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from typing import Dict

from smbus import SMBus
import RPi.GPIO as GPIO

from ac2.constants import STATE_PLAYING, STATE_UNDEF
from ac2.plugins.control.controller import Controller
Expand Down Expand Up @@ -86,8 +85,14 @@ def __init__(self, params: Dict[str, str]=None):
self.intpinpi = 0

# configure GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup((4, 14, 15), GPIO.IN)
try:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup((4, 14, 15), GPIO.IN)
except:
logging.error("Couldn't import RPi.GPIO, won't load powercontroller module")
self.finished = True
return

if params is None:
params = {}
Expand Down

0 comments on commit 3cf821f

Please sign in to comment.