Clarification of how Hass interacts with Appdaemon

Okay, I’m really struggling to understand how appdaemon works with home assistant.

My plan was to use appdaemon so I can code in python making it easier for me to interact with my Arduino/google sheets. lol at me apparently. I’ve installed supervised home assistant on a RPI 4, followed up appdaemon and text editor in the add on the store. According to the logs everything is fine and running.

What I’m trying to do is create a button that I can attach to either the Lovelace and or HAdashboard that triggers a python script.

I’m trying to follow:

I’ve updated the app.yaml to include:

  module: doorbell_notification
  class: DoorBellNotification
  sensor: sensor.doorbell

with my python script including:

from datetime import datetime, timedelta

class DoorBellNotification(hass.Hass):

    def initialize(self):
        self.log('initializing')
        # initialize last_ring variable to avoid extra `If` condition
        self.last_ring = datetime.now() - timedelta(seconds= 35)
        self.listen_state(self.on_doorbell_press, self.args["sensor"], new="on") 

    def on_doorbell_press(self, entity, attribute, old, new, kwargs):
        if self.last_ring < datetime.now() - timedelta(seconds= 30):
            self.last_ring = datetime.now()
            self.log('sending notification')

butttttt I don’t get where to put the entity:

sensor.doorbell

I tried just adding sensor.doorbell to the on of the dashboard templates but it returns not found./its not showing up in my entities list.

which leads me to the next question, say if i wanted to start this script only if i was to turn a switch on via either of the two dashboards, would i just set up a dummy switch such as:

input_boolean:
  dummy_switch:
switch:
  - platform: template
    switches:
      dummy:
        value_template: "{{ is_state('input_boolean.dummy_switch', 'on') }}"
        turn_on:
          - service: input_boolean.turn_on
            entity_id: input_boolean.dummy_switch
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch
        turn_off:
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch

and then just pick up input_boolean.dummy_switch in my python?

any help would be great.

You need to set up a sensor (eg a physical switch) called sensor.doorbell in home assistant.

@nickrout so for example:

  doorbell:
switch:
  - platform: template
    switches:
      doorbell:
        value_template: "{{ is_state('sensor.doorbell', 'on') }}"
        turn_on:
          - service: input_boolean.turn_on
            entity_id: sensor.doorbell
          - service: input_boolean.turn_off
            entity_id: sensor.doorbell
        turn_off:
          - service: input_boolean.turn_off
            entity_id: sensor.doorbell

or is there a neater/better way to do this?