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

force delay after sending any IR command #96

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 12 additions & 30 deletions custom_components/smartir/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,34 +560,13 @@ async def _send_command(

try:
if state == STATE_OFF:
if (
self._hvac_mode == HVACMode.COOL
and "off_cool" in self._commands.keys()
and isinstance(self._commands["off_cool"], str)
off_mode = "off_" + self._hvac_mode
if off_mode in self._commands.keys() and isinstance(
self._commands[off_mode], str
):
_LOGGER.debug("Found 'off_cool' operation mode command.")
await self._controller.send(self._commands["off_cool"])
elif (
self._hvac_mode == HVACMode.HEAT
and "off_heat" in self._commands.keys()
and isinstance(self._commands["off_heat"], str)
):
_LOGGER.debug("Found 'off_heat' operation mode command.")
await self._controller.send(self._commands["off_heat"])
elif (
self._hvac_mode == HVACMode.FAN_ONLY
and "off_fan_only" in self._commands.keys()
and isinstance(self._commands["off_fan_only"], str)
):
_LOGGER.debug("Found 'off_fan_only' operation mode command.")
await self._controller.send(self._commands["off_fan_only"])
elif (
self._hvac_mode == HVACMode.DRY
and "off_dry" in self._commands.keys()
and isinstance(self._commands["off_dry"], str)
):
_LOGGER.debug("Found 'off_dry' operation mode command.")
await self._controller.send(self._commands["off_dry"])
_LOGGER.debug("Found '%s' operation mode command.", off_mode)
await self._controller.send(self._commands[off_mode])
await asyncio.sleep(self._delay)
elif "off" in self._commands.keys() and isinstance(
self._commands["off"], str
):
Expand All @@ -599,16 +578,18 @@ async def _send_command(
):
# prevent to resend 'off' command if same as 'on' and device is already off
_LOGGER.debug(
"As 'on' and 'off' commands are identical and device is already in requested '%s' state skipping sending '%s' command",
"As 'on' and 'off' commands are identical and device is already in requested '%s' state, skipping sending '%s' command",
self._state,
"off",
)
else:
_LOGGER.debug("Found 'off' operation mode command.")
await self._controller.send(self._commands["off"])
await asyncio.sleep(self._delay)
else:
_LOGGER.error(
"Missing device IR code for any of off/off_cool/off_heat/off_fan operation mode."
"Missing device IR code for 'off' or '%s' operation mode.",
off_mode,
)
return
else:
Expand All @@ -626,7 +607,7 @@ async def _send_command(
):
# prevent to resend 'on' command if same as 'off' and device is already on
_LOGGER.debug(
"As 'on' and 'off' commands are identical and device is already in requested '%s' state skipping sending '%s' command",
"As 'on' and 'off' commands are identical and device is already in requested '%s' state, skipping sending '%s' command",
self._state,
"on",
)
Expand Down Expand Up @@ -788,6 +769,7 @@ async def _send_command(
return

await self._controller.send(commands)
await asyncio.sleep(self._delay)

self._on_by_remote = False
self._state = state
Expand Down
3 changes: 3 additions & 0 deletions custom_components/smartir/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,15 @@ async def _send_command(self, state, speed, direction, oscillate):
if state == STATE_OFF:
if "off" in self._commands:
await self._controller.send(self._commands["off"])
await asyncio.sleep(self._delay)
else:
_LOGGER.error("Missing device IR code for 'off' mode.")
return
else:
if oscillate:
if "oscillate" in self._commands:
await self._controller.send(self._commands["oscillate"])
await asyncio.sleep(self._delay)
else:
_LOGGER.error(
"Missing device IR code for 'oscillate' mode."
Expand All @@ -300,6 +302,7 @@ async def _send_command(self, state, speed, direction, oscillate):
await self._controller.send(
self._commands[direction][speed]
)
await asyncio.sleep(self._delay)
else:
_LOGGER.error(
"Missing device IR code for direction '%s' speed '%s'.",
Expand Down
Loading