Open remlei opened 2 years ago
Good news! After coming across your issue and trying the suggested fix, I discovered they fixed it in 4.1.1! After updating to 4.1.1, I edited the fan (LocalTuya > Configure > Edit a device), and when it comes to the page where you configure the DPs, right at the bottom is a new option "int or str". If your fan was having issues previously, just set it to "int" and it should work now. I guess some fans required a string value rather than integer, and we just happened to have fans that used the other. Now with this new setting, it satisfies all types of Tuya fans!
Good news! After coming across your issue and trying the suggested fix, I discovered they fixed it in 4.1.1! After updating to 4.1.1, I edited the fan (LocalTuya > Configure > Edit a device), and when it comes to the page where you configure the DPs, right at the bottom is a new option "int or str". If your fan was having issues previously, just set it to "int" and it should work now. I guess some fans required a string value rather than integer, and we just happened to have fans that used the other. Now with this new setting, it satisfies all types of Tuya fans!
Yeah? I'm on 4.1.1 too, and HA latest Nov release in a Docker container, but I can't see that unfortunately. Anything else you might have done to get this option maybe?
I realise now, this has actually gone backwards for me. I had employed the workaround mods to fan.py but have updated to 4.1.1 and this is now not working. Looking at fan.py now, I can see it implies a configuration option as described above for CONF_FAN_DPS_TYPE, but this is missing in the HA integration UI for me and so the code assumes str
type.
I've reversed the logic as a workaround that suits my situation:
Changed...
self._dps_type = int if self._config.get(CONF_FAN_DPS_TYPE) == "int" else str
To...
self._dps_type = str if self._config.get(CONF_FAN_DPS_TYPE) == "str" else int
@rossco555 it's possible that the UI only shows up when you add a new device as I did that a few times while troubleshooting this. Have you tried deleting the device and adding it again via localtuya?
@rossco555 it's possible that the UI only shows up when you add a new device as I did that a few times while troubleshooting this. Have you tried deleting the device and adding it again via localtuya?
Thanks for the suggestion. I'll give that a try but may not get to it immediately. Will revert.
@jedimdan I gave that a try just now but failed trying to remove a device: Settings > Integrations > localTuya Configure > Edit a Device > unchecked the entity name at bottom and clicked Submit, but I get:
An unknown error occurred. See log for details.
Traceback (most recent call last):
File "/config/custom_components/localtuya/config_flow.py", line 580, in async_step_configure_device
self.dps_strings = await validate_input(self.hass, user_input)
File "/config/custom_components/localtuya/config_flow.py", line 247, in validate_input
data[CONF_DEVICE_ID],
KeyError: 'device_id'
@rossco555 You have to delete the device from HA, not localtuya. Open the device in HA, click on the 3 dots in the Device info card, and click on "Delete".
The problem
Environment
- Localtuya version: 4.0.1 and 4.1.0
- Last working localtuya version (if known and relevant):
- Home Assistant Core version: 2022.07.07 and 2022.09.04
- [] Are you using the Home Assistant Tuya Cloud component ?
- [] Are you using the Tuya App in parallel ?
Steps to reproduce
- usual steps to add a new tuya device to the integration
- choose fan on selection
- set the DPS for related setting
- done, now attempt to control the fan speed and it turns off
Configuration
configuration.yaml
orconfig_flow
DP dump
"dps_strings": [ "1 (value: True)", # Power State "2 (value: 0)", # Timer setting in seconds "3 (value: level_1)", #setting for fan speed? doesnt seem to do anything regardless of level "4 (value: 100)" #setting for fan speed, this one that actually controls the fan speed, value 1-100 (integer) ],
Provide Home Assistant taceback/logs
Additional information
workaround: https://community.home-assistant.io/t/local-tuya-fan-controller/306985/45
basically edit the fan.py and remove the string function. save changes and restart HA, now everything works.
How did you take the dump of the DP settings? Cant figure out what DP is for what. Help appreciated.
I used the iot.tuya.com via API Explorer to dump the DPs at least back then but for some odd reason they removed it so, the only possible way to dump this is via tinytuya. it list all the possible DP ID numbers, its all up to you to find out which one DP correspond to but usually you can get each DP number funtions via API explorer on iot tuya website, look for the "Get Device Specification" under "General Device Management", each function corresponds to the DPs you have dumped using tinytuya all in sequntial, the first DP correspond to the first function, 2nd... 3rd... until you get to the last DP.
The problem
Environment
Steps to reproduce
Configuration
configuration.yaml
orconfig_flow
DP dump
Provide Home Assistant taceback/logs
Additional information
workaround: https://community.home-assistant.io/t/local-tuya-fan-controller/306985/45
basically edit the fan.py and remove the string function. save changes and restart HA, now everything works.