Skip to content

Commit

Permalink
Merge pull request #18 from litinoveweedle/fan_only_temperatures_compat
Browse files Browse the repository at this point in the history
Fan only temperatures compatibility
  • Loading branch information
litinoveweedle authored Jun 2, 2024
2 parents c77d38b + da2c160 commit 3e8f29c
Showing 1 changed file with 39 additions and 31 deletions.
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

0 comments on commit 3e8f29c

Please sign in to comment.