Is it possible to have multiple callback constraints?

Hi,

I love callback constraints feature from AppDaemon, however, there is something that I bumped into that does not allow me to extendedly use it. I use them with the ControllerX, an application that allows you to bind controllers with devices. Callback constraints are used to enable or disable an application depending on the condition, normally a condition involving the state of a light or a media player, so the configuration would look like this:

example_app:
  module: XXXX
  class: XXXX
  constrain_input_boolean: light.light1,on

This works great and I love it, the things is if I want to add another entity constraint I cannot add another condition under the constrain_input_boolean (or at least I could not see in the documentation, this is why I am asking). However, I do the trick of using the constrain_input_select:

example_app:
  module: XXXX
  class: XXXX
  constrain_input_boolean: light.light1,on
  constrain_input_select: light.light2,on

This also works, but the problem is if I want to add another light or other condition, the keys are already taken. I tried to add an array and other things but I could not make it work. Is this something is not implemented on AppDaemon or is there another workaround for this without involving Python code in the applications?

I would also like to thank the contributors of AppDaemons since it is a really cool project and it really saved me from really long YAML configurations with HA automations.

Thanks,
Xavi M.

Hi Xavi, did you try creating your own custom constraints yet? You could then feed the inputs through the app configuration.
Or is this not an option because of this:

I did not know about the the custom constraints, but I would like to avoid changing any python code if possible. If there is no workaround, I might end up using the custom constraints or code myself a condition attribute.

Thank you :slight_smile:

May I ask why?

I think this is a limitation from AppDaemon that they provided a workaround for with the custom constraints. As far as I can see in hassapi.py, there’s no possibility to add multiple input booleans.

I have been using and recommending callback constraints to people when using ControllerX as a way of adding conditions. Up until now, I haven’t had the need for adding new code for condition checking since it was done through AppDaemon. So at first, I wanted to explore if there was any other way of doing so. However as you already pointed out, the existing constraint only works with one condition.

Knowing now about Custom constraints, I will probably go that route then.

Thank you for your help @Burningstone

1 Like