Skip to content
This repository was archived by the owner on Apr 12, 2022. It is now read-only.

Add a workaround for low speed open/close #112

Merged
merged 4 commits into from
May 11, 2021
Merged

Conversation

nbeernink
Copy link
Contributor

This (re)uses position_low_speed for low speed close and open because the Somfy API currently does not provide this parameter on the rs100 on open/close commands and I would very much like to open/close them quietly via Home Assistant.

I tested the payload using the Somfy web API. Hopefully this workaround makes it possible with your library :)
Please let me know if this could be made prettier!

@nbeernink nbeernink requested a review from tetienne as a code owner April 27, 2021 21:26
@tetienne
Copy link
Owner

Hi, thx for this contribution. May I ask how you plan to use this for HA? The integration does not support yet the silent mode (can be done globally through an integration option or through a switch within each device).

def close(self) -> None:
self.send_command(Command("close"))
def close(self, low_speed: Optional[int] = False) -> None:
command = Command("position_low_speed", Parameter("position", 0) if low_speed else "close")
Copy link
Owner

Choose a reason for hiding this comment

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

0 means opened for Somfy and 100 closed:

return self.get_position() == 100

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@nbeernink
Copy link
Contributor Author

Hi, thx for this contribution. May I ask how you plan to use this for HA? The integration does not support yet the silent mode (can be done globally through an integration option or through a switch within each device).

Yes, I checked the code and saw there was no support in HA for this yet. I figured I would first PR this and then attempt to add a contribution to Home Assistant's code in order to make it usable. Eventually it would need to pass the option to this code. :)

My personal preference would be a low-speed switch per device. But a global option makes sense too. But might be tricky to implement this considering houses can come with different roller shutters which do not support position_low_speed (like mine). Need to figure out the capabilities and present a switch if there is support.

def open(self) -> None:
self.send_command(Command("open"))
def open(self, low_speed: Optional[int] = False) -> None:
command = Command("position_low_speed", Parameter("position", 0) if low_speed else "open")
Copy link
Owner

Choose a reason for hiding this comment

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

Can you please call set_position if low_speed is True else open?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's what the code does now? Do I need to change anything else?

@nbeernink
Copy link
Contributor Author

Yes, that's much more readable! :)

@nbeernink
Copy link
Contributor Author

Is there anything else I can do to get this merged?

@tetienne
Copy link
Owner

I didn't see the reviens request.

Thx for your PR 🙏

@tetienne
Copy link
Owner

One last thing, you need to rebase your branch:

  • git fetch --all
  • git rebase upstream/master
  • conflict -> accept their

Niek Beernink and others added 4 commits May 11, 2021 22:33
This (re)uses position_low_speed for low speed close and open because the
Somfy API currently does not provide this parameter.
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit ea79054 and detected 0 issues on this pull request.

View more on Code Climate.

@nbeernink
Copy link
Contributor Author

One last thing, you need to rebase your branch:

  • git fetch --all
  • git rebase upstream/master
  • conflict -> accept their

Thanks. Done

@tetienne tetienne merged commit 699594d into tetienne:master May 11, 2021
@tetienne tetienne added the enhancement New feature or request label May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants