17 lines
596 B
Python
17 lines
596 B
Python
from appdaemon.plugins.hass.hassapi import Hass
|
|
|
|
|
|
class Leaving(Hass):
|
|
def initialize(self):
|
|
self.listen_state(self.turn_everything_off, entity_id=self.args['person'], old='home')
|
|
|
|
def turn_everything_off(self, entity, attribute, old, new, **kwargs):
|
|
self.log(f'turning everything off')
|
|
self.log(kwargs)
|
|
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
|