I am getting NameError: name 'process_button16' is not defined
error when running the following code.
It also turns on the LEDs without pushing the button....that shouldn't do that...
I am trying to implement a button press action using an app in appdaemon for Home Assistant. I'm a former developer, but not python so I'm banging my head against the keyboard here.... Any help would be most appreciated.
import appdaemon.appapi as appapi
from gpiozero import Button
import RPi.GPIO as GPIO
global button
BUTTON_PIN = 16
button = None
class ButtonSense(appapi.AppDaemon):
GPIO.output(17,GPIO.LOW)
GPIO.output(27,GPIO.LOW)
def initialize(self):
self.log("------- Hello -------")
button = Button(BUTTON_PIN)
button.when_pressed = process_button16()
def process_button16():
GPIO.output(17,GPIO.HIGH)
GPIO.output(27,GPIO.HIGH)
self.log("------- Pressed -------")