rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.84k stars 545 forks source link

Setting fan speed does not turn on the fan #444

Open bendarklighter opened 3 years ago

bendarklighter commented 3 years ago

When the fan is off, setting the fan speed slider to low mid or high does not turn on the fan. Is this intended behaviour?

It changes the fan speed ok when the fan is turned on first. I also have 2 dyson fans integrated using the dyson integrtion and those turn on the fan if the speed slider is set above 0, regardless of whether its on or off (which is what i expected would do).

Steps to replicate:

  1. Turn off fan
  2. Set the speed slider above zero - fan does not turn on

image

1iverea9er commented 3 years ago

I have a similar problem. I have a Hessway CO2 controller installed, with the ability to control the fan. The speed parameter has 4 modes: off, low, mid, high. Perhaps this is the case? The integration has 3 modes: low, mid, high. I can switch speeds from low to high, but I can't turn the fan off. The switch does not work. The slider is also not set to the 0 position (only 33.33, 66.66, 100).

Снимок экрана 2021-04-27 141923

log when trying to set the speed slider to the leftmost position (0):

Logger: custom_components.localtuya.common Source: custom_components/localtuya/pytuya/init.py:240 Integration: LocalTuya integration (documentation, issues) First occurred: 17:24:44 (1 occurrences) Last logged: 17:24:44

[631...76b] Failed to set DP 101 to 0 Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 174, in set_dp await self._interface.set_dp(state, dp_index) File "/config/custom_components/localtuya/pytuya/init.py", line 489, in set_dp return await self.exchange(SET, {str(dp_index): value}) File "/config/custom_components/localtuya/pytuya/init.py", line 451, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 240, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.8/asyncio/tasks.py", line 501, in wait_for raise exceptions.TimeoutError() asyncio.exceptions.TimeoutError

log when loading the server when the speed on the device is set to "off" mode:

Logger: custom_components.localtuya.fan Source: custom_components/localtuya/pytuya/init.py:132 Integration: LocalTuya integration (documentation, issues) First occurred: 18:01:28 (7 occurrences) Last logged: 18:01:39

[631...76b] Speed/fan.speed: Ignoring unknown fan controller state: off

It seems the integration is trying to send a command to set the speed to mode "false". However, the device only understands the "off" command. Any idea to fix this ?

1iverea9er commented 3 years ago

Upd: I fix my problem. It works, but not very good. Use parameter SPEED_OFF fo DP Instead of FALSE: async def async_turn_off(self, **kwargs) -> None: """Turn off the entity.""" await self._device.set_dp(SPEED_OFF, self._dp_id) self.schedule_update_ha_state() However, the switch does not work quite correctly. By default, it is in the enabled position. When you try to switch to the off position, the speed does switch to the off mode, but the switch returns to the on position (the speed mode remains in the off state)

tinglis1 commented 2 years ago

Have a look at #542. It might solve some of your issues.

1iverea9er commented 2 years ago

Upd: I fix my problem. It works, but not very good. Use parameter SPEED_OFF fo DP Instead of FALSE: async def async_turn_off(self, **kwargs) -> None: """Turn off the entity.""" await self._device.set_dp(SPEED_OFF, self._dp_id) self.schedule_update_ha_state() However, the switch does not work quite correctly. By default, it is in the enabled position. When you try to switch to the off position, the speed does switch to the off mode, but the switch returns to the on position (the speed mode remains in the off state)

This solution worked for the G-5 controller model (picture below). image

Now I have purchased the G-7 version of the same controller. image

And I'm having trouble turning off the fan again. In the G-7 version, the shutdown command is "stop" instead of "off" as it was on the G-5.

I tried to replace the command as I did earlier, but it didn't work:

async def async_turn_off(self, **kwargs) -> None: """Turn off the entity.""" await self._device.set_dp("stop", self._dp_id) self.schedule_update_ha_state()

How should I change the code so that the controller receives the correct command?