Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement input parameters for actions #1663

Merged
merged 4 commits into from
Jan 15, 2023
Merged

Conversation

rytilahti
Copy link
Owner

@rytilahti rytilahti commented Jan 9, 2023

This makes the action input parameters accessible through action descriptors.

Here's an excerpt from the actions command for ijai.vacuum.v3 showing some parameter infos:

sweep (sweep)
        sweep:reset-consumable          reset-consumable
                Parameter #1: sweep:consumable-index (consumable-index) (<class 'int'>) choices: 主刷 (1), 边刷 (2), 滤网 (3), 拖布 (4)
        sweep:set-calibration           set-calibration
        sweep:set-room-clean            set-room-clean
                Parameter #1: sweep:clean-room-ids () (<class 'str'>) 
                Parameter #2: sweep:clean-room-mode () (<class 'int'>) choices: 全局 (0), 沿边 (1)
                Parameter #3: sweep:clean-room-oper (clean-room-oper) (<class 'int'>) choices: 停止 (0), 开始 (1), 暂停 (2), 假暂停 (3)
        sweep:set-preference-clean              set-preference-clean
                Parameter #1: sweep:clean-preference (clean-preference) (<class 'str'>) 
                Parameter #2: sweep:clean-current-map (clean-current-map) (<class 'int'>) min: 1, max: 4294967295, step: 1
<--snip-->
language (language)
        language:download-voice         download-voice
                Parameter #1: language:target-voice (target-voice) (<class 'str'>) 
                Parameter #2: language:voice-url (voice-url) (<class 'str'>) 
                Parameter #3: language:voice-mdfive (voice-mdfive) (<class 'str'>) 
        language:get-download-status            get-download-status

Example use:

❯ miiocli genericmiot --ip 127.0.0.1 --token 00000000000000000000000000000000 call language:download-voice '["target-voice", "voice-url", "voice-mdfive"]'
Running command call
['ok']

The simulator is modified to verify the input parameters and return errors if the input is something unexpected:

❯ miiocli genericmiot --ip 127.0.0.1 --token 00000000000000000000000000000000 call language:download-voice '[]'
...
ERROR    Exception: {'code': -3, 'error': "Exception <class 'ValueError'>: Invalid parameter count, was expecting 0 params, got 3"}
❯ miiocli genericmiot --ip 127.0.0.1 --token 00000000000000000000000000000000 call language:download-voice '[1, 2, 3]'
...
ERROR    Exception: {'code': -3, 'error': "Exception <class 'TypeError'>: Param #0: expected string but got <class 'int'>"}

This has not been tested with a real device, if you have one and have tested it, feel free to give me a ping!

@rytilahti rytilahti added this to the 0.6.0 milestone Jan 9, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2023

Codecov Report

Merging #1663 (674f3f5) into master (674f3f5) will not change coverage.
The diff coverage is n/a.

❗ Current head 674f3f5 differs from pull request most recent head 49c4117. Consider uploading reports for the commit 49c4117 to get more accurate results

@@           Coverage Diff           @@
##           master    #1663   +/-   ##
=======================================
  Coverage   80.25%   80.25%           
=======================================
  Files         161      161           
  Lines       16085    16085           
  Branches     3618     3618           
=======================================
  Hits        12909    12909           
  Misses       2913     2913           
  Partials      263      263           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rytilahti rytilahti force-pushed the feat/genericmiot_actions branch from b1ab9c9 to 35c529e Compare January 9, 2023 05:07
@rytilahti rytilahti mentioned this pull request Jan 9, 2023
22 tasks
@rytilahti rytilahti force-pushed the feat/genericmiot_actions branch from 35c529e to 04893f8 Compare January 14, 2023 23:32
@rytilahti rytilahti force-pushed the feat/genericmiot_actions branch from 550cd96 to 49c4117 Compare January 15, 2023 00:03
@rytilahti rytilahti merged commit c4dabeb into master Jan 15, 2023
@rytilahti rytilahti deleted the feat/genericmiot_actions branch January 15, 2023 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants