From 964b7fa0b03580fb35d7de24b21cb72dd749e5cc Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:34:38 -0600 Subject: [PATCH] generic action handler --- apps/cubes/cube.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/cubes/cube.py b/apps/cubes/cube.py index cb44f6a..98367b6 100644 --- a/apps/cubes/cube.py +++ b/apps/cubes/cube.py @@ -19,15 +19,15 @@ class AqaraCube(Mqtt): if action == '': return + if (arg := self.args.get(action, None)) is not None: + self.action_handler(action=action, description=arg) 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 action_handler(self, action: str , description: str): + self.log(f'{self.args["cube"]}: {action}: {description}') def handle_rotate_right(self, payload): self.log(f'{self.args["cube"]}: Rotate right')