I’m still learning with AppDaemon (and py in general, for that matter) but I’ve got everything working great, with one small exception - I can’t figure out how to get the app to stop.
I’m using it to run some custom lighting scenes on my Hue lights. I have a binary sensor in HA that monitors an input boolean, so when I toggle the input to “on” - the AD app starts almost immediately.
I’ve been reading the documentation and this is what I have come up with so far (The initialize is working perfectly, the stop_app, not so much):
import appdaemon.plugins.hass.hassapi as hass class TestClass(hass.Hass): def initialize(self): self.listen_state(self.test, "binary_sensor.test_flash_sensor", new = "on") def stop_app(self): self.listen_state(self.test, "binary_sensor.test_flash_sensor", new = "off") def test(self, entity, attribute, old, new, kwargs): while True: import requests
I left the rest of the code out (the Hue API requests to change light colors, etc)
Appreciate any help you might be able to offer!