Skip to content

Commit

Permalink
Remove condition for IDLE from async_toggle_ridge_fixed()
Browse files Browse the repository at this point in the history
It's unnecessary now.
  • Loading branch information
jirutka committed Oct 15, 2024
1 parent 8ab49e9 commit 5c96ad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The integration will create the following entities for each discovered SMARWI de
| Name | Platform | Category | Description
| ------------------- | ------------- | ---------- | --------------------------------------------------------------------------|
| cover | cover | | Control the window tilt position (open, close, stop, set position). |
| ridge_fix | switch | | Fix or release the ridge (can be used only if the motor is currently not |moving).
| ridge_fix | switch | | Fix or release the ridge. |
| ridge_inside | binary_sensor | diagnostic | Shows if the ridge is inside the device (i.e. it’s operational). |
| rssi | sensor | diagnostic | Monitor WiFi signal strength (disabled by default). |
| calibrated_distance | number | config | Set calibrated distance (finetune setting, disabled by default). |
Expand Down
15 changes: 6 additions & 9 deletions custom_components/smarwi/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,12 @@ async def async_stop(self) -> None:

async def async_toggle_ridge_fixed(self, state: bool) -> None:
"""Fix (True) or release (False) the ridge."""
if state:
if not self.ridge_fixed:
LOGGER.info(f"[{self.name}] Fixing ridge")
await self._async_mqtt_command("stop")
else:
# If the motor is moving, "stop" stops it.
if self.ridge_fixed and self.state_code.is_idle():
LOGGER.info(f"[{self.name}] Releasing ridge")
await self._async_mqtt_command("stop")
if state and not self.ridge_fixed:
LOGGER.info(f"[{self.name}] Fixing ridge")
await self._async_mqtt_command("stop")
elif not state and self.ridge_fixed:
LOGGER.info(f"[{self.name}] Releasing ridge")
await self._async_mqtt_command("stop")

async def async_init(self) -> None:
"""Connect to the device."""
Expand Down

0 comments on commit 5c96ad2

Please sign in to comment.