-
-
Notifications
You must be signed in to change notification settings - Fork 568
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
Gateway raw_child_command #651
Conversation
miio/miioprotocol.py
Outdated
@@ -141,6 +142,9 @@ def send(self, command: str, parameters: Any = None, retry_count=3) -> Any: | |||
|
|||
cmd = {"id": self._id, "method": command} | |||
|
|||
if self.sid is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would much prefer to add a new kwarg-only option extra_params
instead of hardcoding sid here, something like this: 57ff028#diff-91c92bb750c47e7a1d365652c76443edR102 – send()
inside gateway could then be overridden to pass the sid parameter where needed.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. It's just that I'm new to python, I'm just figuring out the syntax as I go. I didn't want to change the method's signature for this fringe feature, but if you have an IDE where you can do this refactoring easily, please do. I'm working with text editor here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll update this PR when I get some time this weekend. Thanks :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I created a separate PR to add the necessary functionality (#653). Could you please rebase this on top of it? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay done. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think this will need to wait for a bit, I'll get that linked PR done and merged (after 0.5.0 release is done), and let's rebase this then on top of the master. Thanks for testing & patience :-)
This allows passing extra items to the main payload body, necessary for adding support for subdevices. This also includes some slight cleanups and better tests for the protocol handling code. Related to rytilahti#651
5cda0fa
to
820cdfe
Compare
* Add extra_parameters to send() This allows passing extra items to the main payload body, necessary for adding support for subdevices. This also includes some slight cleanups and better tests for the protocol handling code. Related to #651 * Fix build * Fix incorrect access, thanks to @fsalomon for pointing this out!
I just merged the extra_parameters PR, could you please rebase this on top of the current master? |
@rytilahti I think this PR can be closed since I think almost everything is already included in the restructure PR: #700 |
Indeed, if there is still something missing, it is probably easier to start anew on top of the current master. |
* Add extra_parameters to send() This allows passing extra items to the main payload body, necessary for adding support for subdevices. This also includes some slight cleanups and better tests for the protocol handling code. Related to rytilahti#651 * Fix build * Fix incorrect access, thanks to @fsalomon for pointing this out!
This adds raw_child_command to gateway device that lets the user specify a child device's SID for the command. This is different from raw_command because the SID is not a "param", it is a top-level key.
Example command (e.g. parent device is lumi.acpartner.v3, child device is lumi.relay.c2acn01):
miiocli --debug gateway --ip 192.168.xxx.xxx --token xxxx raw_child_command lumi.xxxx toggle_ctrl_neutral "[\"channel_0\",\"on\"]"
Also added two devices types
AqaraRelay = 54
(lumi.relay.c2acn01) andAqaraSwitch2 = 135
(lumi.remote.b286acn01) and fixed a small bug related to kwargs