Open tekdru opened 9 months ago
my fix based on https://community.home-assistant.io/t/local-tuya-fan-controller/306985/45.
fan.py line 133+: function definition async_set_percentage (original)
async def async_set_percentage(self, percentage):
"""Set the speed of the fan."""
_LOGGER.debug("Fan async_set_percentage: %s", percentage)
if percentage is not None:
if percentage == 0:
return await self.async_turn_off()
if not self.is_on:
await self.async_turn_on()
if self._use_ordered_list:
await self._device.set_dp(
self._dps_type(
percentage_to_ordered_list_item(self._ordered_list, percentage)
),
self._config.get(CONF_FAN_SPEED_CONTROL),
)
_LOGGER.debug(
"Fan async_set_percentage: %s > %s",
percentage,
percentage_to_ordered_list_item(self._ordered_list, percentage),
)
else:
await self._device.set_dp(
self._dps_type(
math.ceil(
percentage_to_ranged_value(self._speed_range, percentage)
)
),
self._config.get(CONF_FAN_SPEED_CONTROL),
)
_LOGGER.debug(
"Fan async_set_percentage: %s > %s",
percentage,
percentage_to_ranged_value(self._speed_range, percentage),
)
self.schedule_update_ha_state()
change to
async def async_set_percentage(self, percentage):
"""Set the speed of the fan."""
_LOGGER.debug("Fan async_set_percentage: %s", percentage)
if percentage is not None:
if percentage == 0:
return await self.async_turn_off()
if not self.is_on:
await self.async_turn_on()
if self._use_ordered_list:
await self._device.set_dp(
#fix https://community.home-assistant.io/t/local-tuya-fan-controller/306985/45
percentage_to_ordered_list_item(self._ordered_list, percentage)
,
self._config.get(CONF_FAN_SPEED_CONTROL),
)
_LOGGER.debug(
"Fan async_set_percentage: %s > %s",
percentage,
percentage_to_ordered_list_item(self._ordered_list, percentage),
)
else:
await self._device.set_dp(
#fix https://community.home-assistant.io/t/local-tuya-fan-controller/306985/45
math.ceil(
percentage_to_ranged_value(self._speed_range, percentage)
),
self._config.get(CONF_FAN_SPEED_CONTROL),
)
_LOGGER.debug(
"Fan async_set_percentage: %s > %s",
percentage,
percentage_to_ranged_value(self._speed_range, percentage),
)
self.schedule_update_ha_state()
Thanks @grzesw72,
I just try using your code but I'm still getting the same "Unavailable" message after trying to change fan speed. Am I missing something else?
Hello. I'm moved to fork -> https://github.com/xZetsubou/hass-localtuya
śr., 21 lut 2024 o 18:26 tekdru @.***> napisał(a):
Thanks @grzesw72 https://github.com/grzesw72,
I just try using your code but I'm still getting the same "Unavailable" message after trying to change fan speed. Am I missing something else?
— Reply to this email directly, view it on GitHub https://github.com/rospogrigio/localtuya/issues/1495#issuecomment-1957394546, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJGYC7VDUWNNVD6Y6APDMXTYUYU2TAVCNFSM6AAAAAA4ZCW32WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJXGM4TINJUGY . You are receiving this because you were mentioned.Message ID: @.***>
The problem
Device: Ceiling Fan Dimmer Switch DS03 Firmware: 3.3
The on/off function works fine for both the light and fan but whenever I try to change the fan speed, both fan and light becomes "unavailable".
Environment
I haven't tried Tuya Cloud Component, TinyTuya or any previous version of local Tuya.
Steps to reproduce
DP dump
Provide Home Assistant traceback/logs
Additional information