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

Fan only temperatures compatibility #18

Merged
merged 1 commit into from
Jun 2, 2024
Merged
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
70 changes: 39 additions & 31 deletions custom_components/smartir/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,70 +418,78 @@ async def send_command(self, hvac_mode, fan_mode, swing_mode, temperature):

if not hvac_mode in self._commands.keys():
_LOGGER.error(
"Missing device IR code for %s operation mode.", hvac_mode
"Missing device IR code for '%s' operation mode.", hvac_mode
)
return
elif not (
isinstance(self._commands[hvac_mode], dict)
and fan_mode in self._commands[hvac_mode].keys()
and isinstance(self._commands[hvac_mode][fan_mode], dict)
):
_LOGGER.error(
"Missing device IR code for %s fan mode.", fan_mode
"Missing device IR codes for '%s' fan mode.", fan_mode
)
return
elif self._support_swing == True:
if not (
isinstance(self._commands[hvac_mode][fan_mode], dict)
and swing_mode in self._commands[hvac_mode][fan_mode].keys()
swing_mode in self._commands[hvac_mode][fan_mode].keys()
and isinstance(
self._commands[hvac_mode][fan_mode][swing_mode], dict
)
):
_LOGGER.error(
"Missing device IR code for swing mode." + swing_mode
"Missing device IR codes for '%s' swing mode.",
swing_mode,
)
return
elif hvac_mode == HVACMode.FAN_ONLY:
elif (
target_temperature
in self._commands[hvac_mode][fan_mode][swing_mode].keys()
):
await self._controller.send(
self._commands[hvac_mode][fan_mode][swing_mode]
)
elif not (
isinstance(
self._commands[hvac_mode][fan_mode][swing_mode], dict
self._commands[hvac_mode][fan_mode][swing_mode][
target_temperature
]
)
and target_temperature
elif (
hvac_mode == HVACMode.FAN_ONLY
and "-"
in self._commands[hvac_mode][fan_mode][swing_mode].keys()
):
# fan_only mode sometimes do not support temperatures
# (same code is used for all temperatures)
await self._controller.send(
self._commands[hvac_mode][fan_mode][swing_mode]["-"]
)
else:
_LOGGER.error(
"Missing device IR code %s target temperature.",
"Missing device IR code '%s' for target temperature.",
target_temperature,
)
return
else:
await self._controller.send(
self._commands[hvac_mode][fan_mode][swing_mode][
target_temperature
]
)
else:
if (
not isinstance(self._commands[hvac_mode][fan_mode], dict)
and hvac_mode == HVACMode.FAN_ONLY
target_temperature
in self._commands[hvac_mode][fan_mode].keys()
):
await self._controller.send(
self._commands[hvac_mode][fan_mode]
self._commands[hvac_mode][fan_mode][target_temperature]
)
elif not (
isinstance(self._commands[hvac_mode][fan_mode], dict)
and target_temperature
in self._commands[hvac_mode][fan_mode].keys()
elif (
hvac_mode == HVACMode.FAN_ONLY
and "-" in self._commands[hvac_mode][fan_mode].keys()
):
# fan_only mode sometimes do not support temperatures
# (same code is used for all temperatures)
await self._controller.send(
self._commands[hvac_mode][fan_mode]["-"]
)
else:
_LOGGER.error(
"Missing device IR code for %s target temperature.",
"Missing device IR code for '%s' target temperature.",
target_temperature,
)
return
else:
await self._controller.send(
self._commands[hvac_mode][fan_mode][target_temperature]
)

self._on_by_remote = False
self._hvac_mode = hvac_mode
Expand Down
Loading