[AppDaemon] Trigger a AppDaemon function from Lovelace Button

Hi,

I’m coming from ioBroker and was excessively using the Javascripts for automation.

I really like the look and feel of Home Assistant but I need to find an alternative to the JS preferably in Python.
I am a embedded programmer and I really don’t like these Automations, Scenes and pseudo YAML “scripts”. I know some may prefere them but I don’t.

So I searched for a possibility for coding my scripts natively in Python.

I found AppDaemon, managed to install it and implemented my first test script.
It is time triggered and reads and sets some MQTT devices.

NICE. I thought I can automize all my things over python scripts.

But now to the problem.
I don’t get it how to define functions and make it possible to trigger them by a normal HA lovelace button.
First I thought that I need something like:
self.register_service("myservices/pc_lautspr", self.test_callback)
But I it still makes no sense and maybe AppDaemon are not the right thing to go?
I tried to create a new HA “Automation” and in my theory I thought it should be possible to trigger the function by adding a “Call Service” Action to the “Automation”. But there is nothing to select that has a similar name.

In the end I just noticed that I have no plan where to start and find out how to create a simple lovelace dash and trigger a python function from a button.

Please give me a hint.

I think I have come one step further:
It is possible to create so called “Helpers” that are kind of variables that can be used on the frontend and also from AppDaemon.
Seems to be very basic but I was not aware of this.
To create a Helper go to:
“Settings” → “Devices & Services” → Tab “Helpers” → “Create Helper” → …

You can define a button with a tap action of calling a script, which in turn fires an event and have an AD app listen for that event. You can also attach data to each call all the way from the button to the AD app.