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

Gateway raw_child_command #651

Closed
wants to merge 7 commits into from

Conversation

fsalomon
Copy link
Contributor

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) and AqaraSwitch2 = 135 (lumi.remote.b286acn01) and fixed a small bug related to kwargs

@fsalomon
Copy link
Contributor Author

Relate to #632 and #650.

@coveralls
Copy link

coveralls commented Mar 25, 2020

Coverage Status

Coverage increased (+0.5%) to 73.692% when pulling 820cdfe on fsalomon:gateway-raw-child-command into e181169 on rytilahti:master.

@@ -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:
Copy link
Owner

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?

Copy link
Contributor Author

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.

Copy link
Owner

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 :-)

Copy link
Owner

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay done. Thanks!

Copy link
Owner

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
rytilahti added a commit that referenced this pull request Apr 19, 2020
* 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!
@rytilahti
Copy link
Owner

I just merged the extra_parameters PR, could you please rebase this on top of the current master?

@starkillerOG
Copy link
Contributor

@rytilahti I think this PR can be closed since I think almost everything is already included in the restructure PR: #700

@rytilahti
Copy link
Owner

Indeed, if there is still something missing, it is probably easier to start anew on top of the current master.

@rytilahti rytilahti closed this May 27, 2020
xvlady pushed a commit to xvlady/python-miio that referenced this pull request May 9, 2021
* 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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants