Skip to content

Commit

Permalink
Avoid restart program when resuming from pause (issue #627)
Browse files Browse the repository at this point in the history
  • Loading branch information
ollo69 committed Feb 5, 2024
1 parent 43d1336 commit 6f9828f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions custom_components/smartthinq_sensors/wideq/devices/washerDryer.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(
self._remote_start_status = None
self._remote_start_pressed = False
self._power_on_available: bool = None
self._initial_bit_start = False

@cached_property
def _state_power_off(self):
Expand Down Expand Up @@ -199,7 +200,10 @@ def _prepare_command_v1(self, cmd, key):
# is the 1st bit of Option2. This probably should be reviewed
# to use right address from model_info
if key and key == "Start" and dt_key == "Option2":
dt_value = str(int(dt_value) | 1)
if self._initial_bit_start:
dt_value = str(int(dt_value) | 1)
else:
dt_value = str(int(dt_value) ^ (int(dt_value) & 1))
str_data = str_data.replace(f"{{{{{dt_key}}}}}", dt_value)
_LOGGER.debug("Command data content: %s", str_data)
encode = cmd.pop("encode", False)
Expand Down Expand Up @@ -245,7 +249,10 @@ def _prepare_command_v2(self, cmd, key: str):
else:
cmd_data_set[s_course_key] = "NOT_SELECTED"
elif cmd_key == self.getkey("initialBit"):
cmd_data_set[cmd_key] = "INITIAL_BIT_ON"
if self._initial_bit_start:
cmd_data_set[cmd_key] = "INITIAL_BIT_ON"
else:
cmd_data_set[cmd_key] = "INITIAL_BIT_OFF"
else:
cmd_data_set[cmd_key] = status_data.get(cmd_key, cmd_value)
res_data_set = {WM_ROOT_DATA: cmd_data_set}
Expand Down Expand Up @@ -336,6 +343,9 @@ def remote_start_enabled(self) -> bool:
self._state_power_on_init,
self._state_pause,
]:
self._initial_bit_start = (
self._status.internal_run_state == self._state_power_on_init
)
return True
return False

Expand Down

0 comments on commit 6f9828f

Please sign in to comment.