-
Notifications
You must be signed in to change notification settings - Fork 574
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
update to the new fan platform #542
Conversation
Hi @tinglis1 , wouldn't it be better to follow the same pattern as we have for cover? i.e. for the direction provide several sets, one being "forward/reverse". Same thing for the ordered list, just provide "small/mid/large". Reason being it's easier for the user to setup and I don't think there are that many different options. Take a look at the cover code for inspiration and let me know your thoughts. Also you might need a rebase/merge with upstream to resolve your conflicts. |
I wrote the new platform based on the lack of consistent terms used by the Tuya platform.
For reference I am not a programmer but needed this component to work for my ceiling fans so gave it go at updating it. |
Based on your post in the issue with your DPS mapping what you have for the speed control should work for your fan. |
That field below the oscillation field that doesn't have a title (need to fix that) is the field for selecting the DPS for the fan direction. |
@tinglis1 You have to be careful of these True/False cases. You might need to add some type conversions because the config are strings and the forward/reverse dp might be a boolean. Look at this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thaks for these changes, I have added them to my local tuya and all works perfect except everytime I change fan speed I get the below error but the setting changes just fine.
unsupported operand type(s) for -: 'str' and 'int'
This is missing the use of presets... My air purifier uses the low/mid/high/auto settings, and works great as a preset instead of speeds. Several other fan controllers use these also. auto is a preset, not a fan speed. My ceiling fan controller doesn't use presets, but does use numerical ranges (4 speeds, 1 to 4) Need to create a catalog like https://github.com/make-all/tuya-local implemented for his tuya integration and stop hard-coding these into the program. |
This is the localtuya and the tuya_local catalog entry
|
@ThomasADavis In the interim you could just assign your speed and auto to the names list as they are all on the same DPS. One thing I have noticed is that some presets are on the same DPS as speed and some are on a different one. Sending the preset will be easy enough but on receiving them there will need to be some checks against preset lists to split out presets from speeds when they share a DPS. |
@ThomasADavis On a side note i like the catalogue idea but none of those implementations use the new fan platform and I wasn't skilled enough to update those platforms with the added complexity of config yaml. If only tuya would give some standardization on its DPS fields. |
I have spotted that as well now that I am looking for it. I don't get it every time and I always works. |
yes this was bugging me too, its in line 152, which is just a debug log which is why everything works. (my guess is a copy paste error :))
Just need to update it to use the correct tuple value of the speed range which is what percentage_to_ranged_value expects.
|
Thats just simply saying the ci needs to run before the pr can be merged. @tinglis1 not sure if this is the issue but its something to check, when creating a pr myself it ask if you wanted to give the maintainers (@rospogrigio) write permission.. did you tick that box? |
Can closing and reopening the PR trigger the checks? |
OK I managed to re-run the checks, but the python 3.8 check failed:
Please commit the fix... |
@rospogrigio just need tests to run again |
@tinglis1 would it be possible to update the yaml for the new fan configuration in the readme please: https://github.com/tinglis1/localtuya/blob/master/README.md?plain=1#L64-L66 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested and working
It should pass the checks now but in my last testing my fan is showing as always on. I am not sure if there is an issue with my HA instance. I can do everything like change speed etc. but it shows as on when it is off. I will do some further checks. Please hold off on merging until I have confirmed if it is a local issue to me or something i broke. |
Confirmed that the issue I had around the fan showing as always on was related to the hardware. Turning it off and on fixed that issue. |
I manually merged this with v3.3.0 that was just released as I needed both the update DPS capability for power consumption as well as this fan one. Worked as expected. Would be good if this fan PR can be merged into master soon :) |
Thank you very much everyone who was involved in getting this merged. |
Documentation needs to be updated to mention fan_direction_forward and fan_direction_reverse rather than fan_direction_fwd and fan_direction_rev. https://github.com/tinglis1/localtuya/blob/master/README.md?plain=1#L70-L71 |
Updated to the new fan platform using percentages.
I have modified the fan.py and config flow to:
I have tested with an Arlec Ceiling fan and tried to make the update flexible for as many other devices as possible.
Probably needs some beta testers for more thorough bug finding.
For those using the exiting option in speed lists for small, mid, large these can be done as a comma separated list in named speeds.