15 lines
535 B
Python
15 lines
535 B
Python
from appdaemon.adapi import ADAPI
|
|
|
|
class Leaving(ADAPI):
|
|
def initialize(self):
|
|
self.listen_state(self.turn_everything_off, entity_id=self.args['person'], old='home')
|
|
|
|
def turn_everything_off(self, *args, **kwargs):
|
|
self.log(f'turning everything off')
|
|
for app_name in self.args['apps']:
|
|
try:
|
|
self.get_app(app_name).deactivate(kwargs={'cause': 'leaving'})
|
|
except Exception as e:
|
|
self.log(f'{type(e).__name__}: {e}')
|
|
continue
|