generic action handler
This commit is contained in:
@@ -19,15 +19,15 @@ class AqaraCube(Mqtt):
|
|||||||
|
|
||||||
if action == '':
|
if action == '':
|
||||||
return
|
return
|
||||||
elif (handler := getattr(self, f'handle_{action}', None)):
|
|
||||||
if (arg := self.args.get(action, None)) is not None:
|
if (arg := self.args.get(action, None)) is not None:
|
||||||
self.action_handler(action_description=arg)
|
self.action_handler(action=action, description=arg)
|
||||||
|
elif (handler := getattr(self, f'handle_{action}', None)):
|
||||||
handler(payload)
|
handler(payload)
|
||||||
else:
|
else:
|
||||||
self.log(f'Unhandled cube action: {action}')
|
self.log(f'Unhandled cube action: {action}')
|
||||||
|
|
||||||
def action_handler(self, action_description):
|
def action_handler(self, action: str , description: str):
|
||||||
self.log(f'{self.args["cube"]}: generic action handler: {action_description}')
|
self.log(f'{self.args["cube"]}: {action}: {description}')
|
||||||
|
|
||||||
def handle_rotate_right(self, payload):
|
def handle_rotate_right(self, payload):
|
||||||
self.log(f'{self.args["cube"]}: Rotate right')
|
self.log(f'{self.args["cube"]}: Rotate right')
|
||||||
|
|||||||
Reference in New Issue
Block a user