Configuring Appdaemon Script

Hi all,

I’m having issues with working out how to set up my Appdaemon script to be run by a button on the Home Assistant overview dashboard. I’m very new to HA/RPi/Appdaemon so bear with me.

My app is defined as:

import appdaemon.plugins.hass.hassapi as hass
import RPi.GPIO as GPIO

#
# Hellow World App
#
# Args:
#

class HelloWorld(hass.Hass):

  def initialize(self):
     self.log("Hello from AppDaemon")
     self.log("You are now ready to run Apps!")
  
  def trigger(self):
     self.log("Triggering")
     
     # Board Settings
     
     switchPin = 14
     GPIO.setmode(GPIO.board)
     GPIO.cleanup()
     GPIO.setup(switchPin, GPIO.OUT)
     
     GPIO.output(switchPin, GPIO.HIGH)

So simply, when an event is triggered, I want Appdaemon to output on pin 14.But I don’t know how to set this event up?? I think I need to have the app listening for a state change when a button is pressed?? But I have no idea how to do this.

And yes, I do have a switch set up that triggers this output already, but this is the start of something more complex (I hope).

How do I create a button (entity??) on the Overview dashboard, that will allow me to call the trigger function in my app.

Apologies if this has been asked before, I have tried searching for it, but I cannot find anything that (A) answers my question, and (B) I can follow.

Thanks in advance!

first of all no need to apologize.
you just have no clue how to work with appdaemon, but thats no problem.

i advise you to read through the docs a few times.
esspecially parts like:
https://appdaemon.readthedocs.io/en/dev/HASS_TUTORIAL.html and
https://appdaemon.readthedocs.io/en/dev/APPGUIDE.html

but above all i advise to read through my appdaemon for beginners.

it will explain how you would trigger things
the overview dashboard you call it is known as the HA GUI or the HA fromtend.
creating a button there would for instance be done by adding an input_boolean to your configuration.

2 Likes