generic action handler

This commit is contained in:
John Lancaster
2023-11-24 16:06:07 -06:00
parent 9597cf5942
commit 0deb3eb8f6

View File

@@ -20,10 +20,15 @@ class AqaraCube(Mqtt):
if action == '':
return
elif (handler := getattr(self, f'handle_{action}', None)):
if (arg := self.args.get(action, None)) is not None:
self.action_handler(action_description=arg)
handler(payload)
else:
self.log(f'Unhandled cube action: {action}')
def action_handler(self, action_description):
self.log(f'{self.args["cube"]}: generic action handler: {action_description}')
def handle_rotate_right(self, payload):
self.log(f'{self.args["cube"]}: Rotate right')