silencing warnings

This commit is contained in:
John Lancaster
2024-08-27 19:17:02 -05:00
parent 4114fb4c54
commit fca47b8a60
3 changed files with 9 additions and 11 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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}')