Before adopting to Appdaemon I wrote scripts, and as such they would show up in the browser for easy manual triggering by a click on the “ACTIVATE” button.
Now I would like to do the same to easily trigger my apps, can this be done?
The manual[1] talks about firing an event from script so I tried the following:
But this does not trigger my app that uses listen_state() on the same binary_senosor…
(The app works when I physically trigger the sensor by walking in front of it.)
Hmmm… I was inspired by the set_state() in appdaemon. My assumption was that a script would do the same as if I had created a second app that called it like:
Would a second app work? I’m thinking a script that calls the second app with your proposed event MODE_CHANGE… (Everything to not add specific “debug code” in my first app.)
Agreed, I will probably just add the listen_event for the purpose of triggering from the browser, and try to make it possible to have a dedicated GUI element for each instance of the app.
But I will definitely try the second app approach in order to debug my apps. Thanks!
initialize(...):
listen_state(self.motioncallback,"sensor.motion")
listen_state(self.motioncallback,"input_boolean.test", state="on")
motioncallback(self,...):
motion = self.get_state("sensor.motion")
if self.get_state("input_boolean.test") == "on":
motion = "on"
the appcode
self.turn_off("input_boolean.test")
this way triggering by motion is identical with flipping a boolean on.
set_state could work also, but there are still some problems on the HA side with that.
For now I have settled on a combination of input_boolean and template sensors/switches and running my tests and development on a separate machine. This allows me to play around without killing my production server while still using the same App code and configuration.