Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. """
  2. testing_2:
  3.  module: test_2
  4.  class: Test
  5.  
  6. testing:
  7.  module: test
  8.  class: Test
  9.  dependencies:
  10.    - testing_2
  11.    
  12. """
  13.  
  14.  
  15. # First App
  16. import appdaemon.plugins.hass.hassapi as hass
  17.  
  18. class Test(hass.Hass):
  19.  
  20.   def initialize(self):
  21.     pass
  22.  
  23.   def setup_run_in(self):
  24.     handle = self.run_in(self.cb, 5)
  25.     return handle
  26.  
  27.   def cb(self, kwargs):
  28.     self.logger.log('cb() was called in testing_2.')
  29.  
  30.    
  31. # Second App
  32. import appdaemon.plugins.hass.hassapi as hass
  33.  
  34. class Test(hass.Hass):
  35.  
  36.   def initialize(self):
  37.     self.listen_state(self.test, 'input_boolean.appdaemon_testing')
  38.     self.testing_2 = self.get_app('testing_2')
  39.     self.handle_test = None
  40.     self.should_cancel = False
  41.  
  42.   def test(self, entity, attribute, old, new, kwargs):
  43.     self.log('test() called')
  44.     if self.should_cancel:
  45.       self.cancel_timer(self.handle_test)
  46.       self.log('Cancel self.handle_test.')
  47.     else:
  48.       self.should_cancel = True
  49.       self.handle_test = self.testing_2.setup_run_in()
  50.       self.log('Setup run_in.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement