-
Notifications
You must be signed in to change notification settings - Fork 106
fixed function support_color #34
base: master
Are you sure you want to change the base?
Conversation
This could fix #17 |
It doesn't seem to suffice.
|
So now, |
I just had another look at what is being returned from the API and it's really bogus. The mode reflects what is set in the Tuya smartphone app and toggles between So there is simply no way of reading back or setting the colour with this API endpoint, and that needs fixing on the server side. Now I'm wondering whether @PaulAnnekov or anyone else is in contact with the API provider, because after all, the API was apparently specifically designed for HomeAssisant. |
I wrote many times to Tuya support center, I'm also in contact with one of their account managers, but they seem not to be willing to listen... They are not interested in fixing this... Maybe they should get more of those requests asking to fix their APIs from more users.... |
Just sent them this last night: Hello tuya team, I fount this e-mail address because you are maintainer of the Following project : https://pypi.org/project/tuyapy/ The goal of this API was to provide integration for home-assistant with tuya devices. https://www.home-assistant.io/ https://www.home-assistant.io/integrations/tuya/ You provide services to a large collection of IoT devices. Please consider maintaining a fully available API (RESTFUL ?) so that your customers can easily control them via other softwares than a smarphone app. Usually the best way to do this is provide an API token via your smartphone app when the user is authenticated. If you need help or want some advices on how to create such API I’m willing to help you ! Kind regards, (Yes i'm treating them like they don't know what they're doing by explaining how an API key works) |
The guy mantaining the code left Tuya company... |
…eturn the information anymore. This shouldn't cause problems as long as the user doesn't use another app to control his lights (this is unlikely with home assistant and is better than an exception anyway)
In the meantime, my last commit should bring back some functionnalities for tuya lights without breaking anything. Please review it :) (also it would be a good idea to add some form of unit testing to be sure that everything still works after a dev :D ) |
@zonque can you test the last commit, please? Because I don't have a light bulb from Tuya. |
I mentioned this on the issue, but the constructor for TuyaLight should call the init method of the base class like this: def __init__(self, data, api):
super().__init__(data, api)
self.last_hs_color = None
self.last_brightness = None
self.last_color_temp = None
self.last_state = None Otherwise, you get the error:
I've tested it with that change and it works, but it will still give the error This looks like it can be possibly avoided by changing |
…lues in __init__ and called super()
Done, i provided a valid default value for all "last_" variables. |
If you give me (or point to) some instruction how I can test the PR on my HA instance - I will be glad to help, since I have an RGB tuya (smart life) bulb. I suppose I should replace some code in my instance, yes? |
I would also be happy to test, as I have several tuya RGB bulbs across multiple instances of HA. It would be brilliant if this could be resolved, as several users I introduced to HA were dissuaded by the lack of RGB control of tuya bulbs. |
I'm not exactly sure on how to test... I guess that the best way is to duplicate the tuya integration from HA core, place it in the custom_component folder along with the modified version of the python library. By doing so i think that HA will take the custom_component version in priority instead of the one present in the core and thus use the modified version. Never tried it though because i decided to migrate my RGB strip (only tuya device) to a shelly RGB. |
Looks like this patch does nothing for me. I've patch the runtime and deleted the |
@scaytrase The way I understand it, this fix will return support_color as true if the light is in colour mode, so try either switching it to colour mode outside of Home Assistant (e.g. in the Smart Life/Tuya app) or by using a script in Home Assistant which turns it on to a specific colour. |
wow, that worked! Yea, looks great! UI is still a bit unresponsive, but as far as I understand it's the problem of tuya integration itself thanks @gadgetchnnel ! |
but looks like I found a problem. Picking white colour from the cirle turns off the colour mode, so I have to go back to app to restore it. |
Is this fix updating the colour status in HA if I change che colour from Smart Life app? As I understand no, right? As the tuya API doesn't support it... Btw I'm chasing one of the Tuya account manager and he promised me they are going to fix the APIs.... |
no, it's not |
Correct, it won't actualize data if the tuya API doesn't return it. if some day the tuya API returns that data, it will be returned as expected.
I suppose that when you put the light to "white" it switches from "colour" mode to "temperature" or something else. This will then tell HA that the bulb no longer supports "color"... I'll look at what i can do to fix this but this could be tricky... |
Maybe "support_color_temp" needs change but i don't have a device to know what value is used by the API.
@scaytrase could you send me the content of self.data for the light when you put it on "color_temperature" mode? This would help me improve the cache for the cache of "color_temp_mode" |
Not sure if this is helpful but I've noticed that if I force my lights to use the larger brightness range (10-1000) in the integration settings in HA I can force them to switch back from color mode to white mode. If already in RGB mode you lower the brightness down to about 20-25%, then pick white (you'll get the semi-white from the RGB combination, but at a very low brightness value), and lastly increase brightness until it goes over to just white. Switching back to RGB just requires picking a color since the color wheel stays. ( I did not need to force color support except for some lights which did not announce it at all). Once I did this it seems to remember the last brightness used in white mode and switching to it just requires selecting white on the color wheel. I'm on the 2020.12.1 HA release with stock Tuya integration code. |
that wasn't working due to a change in the API
This broke of course HomeAssistant integration resulting in the color picker not showing because the SUPPORT_COLOR wasn't set.
I don't know if this breaks other lights but this fixes my Lumary LED Strip