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

@@ -71,21 +71,21 @@ class SleepSetter(Hass, Mqtt):
self.all_off()
try:
self.call_service('scene/turn_on', entity_id=self.scene)
except:
except Exception:
return
else:
self.log(f'Turned on scene: {self.scene}')
# self.turn_on(self.scene)
def handle_button(self, event_name, data, **kwargs):
topic = data['topic']
# topic = data['topic']
# self.log(f'Button event for: {topic}')
try:
payload = json.loads(data['payload'])
action = payload['action']
except json.JSONDecodeError:
self.log(f'Error decoding JSON from {data["payload"]}', level='ERROR')
except KeyError as e:
except KeyError:
return
else:
self.handle_action(action)
@@ -103,19 +103,19 @@ class SleepSetter(Hass, Mqtt):
self.on_apps()
def all_off(self):
self.log(f'Deactivating apps')
self.log('Deactivating apps')
for app_name in self.args['off_apps']:
try:
self.get_app(app_name).deactivate(cause='sleep setter')
except:
except Exception:
self.log(f'Failed to deactivate {app_name}')
continue
self.log(f'Turning off entities')
self.log('Turning off entities')
for entity in self.args['off_entities']:
try:
self.turn_off(entity)
except:
except Exception:
self.log(f'Failed to turn off {entity}')
continue
@@ -124,7 +124,7 @@ class SleepSetter(Hass, Mqtt):
for app_name in on_apps:
try:
self.get_app(app_name).activate(kwargs={'cause': 'sleep setter'})
except:
except Exception:
return
else:
self.log(f'Activated {app_name}')