silencing warnings
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
|
||||||
|
|
||||||
from appdaemon.adapi import ADAPI
|
|
||||||
from appdaemon.adbase import ADBase
|
from appdaemon.adbase import ADBase
|
||||||
from appdaemon.plugins.hass.hassapi import Hass
|
from appdaemon.plugins.hass.hassapi import Hass
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Leaving(Hass):
|
|||||||
self.listen_state(self.turn_everything_off, entity_id=self.args['person'], old='home')
|
self.listen_state(self.turn_everything_off, entity_id=self.args['person'], old='home')
|
||||||
|
|
||||||
def turn_everything_off(self, entity, attribute, old, new, **kwargs):
|
def turn_everything_off(self, entity, attribute, old, new, **kwargs):
|
||||||
self.log(f'turning everything off')
|
self.log('turning everything off')
|
||||||
self.log(kwargs)
|
self.log(kwargs)
|
||||||
for app_name in self.args['apps']:
|
for app_name in self.args['apps']:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -71,21 +71,21 @@ class SleepSetter(Hass, Mqtt):
|
|||||||
self.all_off()
|
self.all_off()
|
||||||
try:
|
try:
|
||||||
self.call_service('scene/turn_on', entity_id=self.scene)
|
self.call_service('scene/turn_on', entity_id=self.scene)
|
||||||
except:
|
except Exception:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.log(f'Turned on scene: {self.scene}')
|
self.log(f'Turned on scene: {self.scene}')
|
||||||
# self.turn_on(self.scene)
|
# self.turn_on(self.scene)
|
||||||
|
|
||||||
def handle_button(self, event_name, data, **kwargs):
|
def handle_button(self, event_name, data, **kwargs):
|
||||||
topic = data['topic']
|
# topic = data['topic']
|
||||||
# self.log(f'Button event for: {topic}')
|
# self.log(f'Button event for: {topic}')
|
||||||
try:
|
try:
|
||||||
payload = json.loads(data['payload'])
|
payload = json.loads(data['payload'])
|
||||||
action = payload['action']
|
action = payload['action']
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
self.log(f'Error decoding JSON from {data["payload"]}', level='ERROR')
|
self.log(f'Error decoding JSON from {data["payload"]}', level='ERROR')
|
||||||
except KeyError as e:
|
except KeyError:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.handle_action(action)
|
self.handle_action(action)
|
||||||
@@ -103,19 +103,19 @@ class SleepSetter(Hass, Mqtt):
|
|||||||
self.on_apps()
|
self.on_apps()
|
||||||
|
|
||||||
def all_off(self):
|
def all_off(self):
|
||||||
self.log(f'Deactivating apps')
|
self.log('Deactivating apps')
|
||||||
for app_name in self.args['off_apps']:
|
for app_name in self.args['off_apps']:
|
||||||
try:
|
try:
|
||||||
self.get_app(app_name).deactivate(cause='sleep setter')
|
self.get_app(app_name).deactivate(cause='sleep setter')
|
||||||
except:
|
except Exception:
|
||||||
self.log(f'Failed to deactivate {app_name}')
|
self.log(f'Failed to deactivate {app_name}')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.log(f'Turning off entities')
|
self.log('Turning off entities')
|
||||||
for entity in self.args['off_entities']:
|
for entity in self.args['off_entities']:
|
||||||
try:
|
try:
|
||||||
self.turn_off(entity)
|
self.turn_off(entity)
|
||||||
except:
|
except Exception:
|
||||||
self.log(f'Failed to turn off {entity}')
|
self.log(f'Failed to turn off {entity}')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ class SleepSetter(Hass, Mqtt):
|
|||||||
for app_name in on_apps:
|
for app_name in on_apps:
|
||||||
try:
|
try:
|
||||||
self.get_app(app_name).activate(kwargs={'cause': 'sleep setter'})
|
self.get_app(app_name).activate(kwargs={'cause': 'sleep setter'})
|
||||||
except:
|
except Exception:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.log(f'Activated {app_name}')
|
self.log(f'Activated {app_name}')
|
||||||
|
|||||||
Reference in New Issue
Block a user