Enable/Disable AppDaemon automation like normal HA automation

Did anybody already create something so that it is easy to disable a AppDaemon automation? I know I could create an input_boolean and check that but I wonder if there are perhaps better solutions.

Using the set_state I can create the relevant automations programmatically (using this) but when I then enable multiple automations at once, it fails (due to entity_id being a list instead of a string)

You’ll need to modify that code to accept entity_id possibly being a list and searching for self.input_boolean in that list.

instead of trying to use a list for set_state, you can use a for next loop trough the list.
so not:

self.set_state(entity_list,state = something)

but

for entity in entity_list:
  self.set_state(entity,state = something)
1 Like

Ok, and do you guys use the last_triggered and friendly_name?

do we use it for what?
yeah i got friendly names, but i hardly use them in the programming
last_triggered i dont know what you mean with that.

Like @ReneTode said, friendly_name is something I set on almost any entity created in AppDaemon, but, there’s hardly any programming involved with that. Most of my apps allow for a “friendly_name” configuration element, and that is simply passed on in the attributes of the sensor that I publish to Home Assistant.

For last_triggered, In the rare cases where I feel the need to publish an “automation” entity to Home Assistant, then I’ll make sure last_triggered is set so that it looks and acts like any other automation entity in Home Assistant. And, while I’ve done this in the past, currently, none of my 150+ AppDaemon apps publish a “automation” entity. For me, it’s just extra work with no reward.

If I need an AppDaemon app that can be triggered in a Home Assistant automation, I generally use an “event” for that. There’s less setup involved and the Home Assistant YAML isn’t any more difficult to write.

I also only publish entities or attributes that I need to use in a Home Assistant automation. For instance, I have an AppDaemon app that monitors alarms set on Alexa devices, and, when the alarm time comes, the AppDaemon app triggers specific scripts in Home Assistant (I use this for multi-room notification of a kitchen alarm, as well as sunrise style wakeups in bedrooms). There’s nothing about that particular app that I need to see in Home Assistant. It watches the alarms and calls the scripts at the appropriate times. So I don’t publish an entity at all to Home Assistant.

1 Like

Have a look at the callback constraints here if you havn’t already.
https://appdaemon.readthedocs.io/en/latest/APPGUIDE.html?highlight=constraint#callback-constraints

1 Like