tuya-local
tuya-local copied to clipboard
Error Unable To Connect
Hi,
Im trying to add my first device, which is a light.
this is a fresh install with nothing else setup other than this repository
Added repository as a custom one. Rebooted. then went to add integrations and selected tuya local
Retrieved the deviceid and local key, but I get an error when trying to add device,
Here are the details in the log.
Possible duplicate of #225. You need to ensure your Tuya app is not open on a phone, or the phone is not on the local WiFi network. Other possible causes are the details being wrong (local key is refreshed if you re-pair the device, IP address may be dynamically allocated - you need to configure the router to always use the same address for your Tuya devices) or the IP address not being reachable from HA due to network configuration.
IP address is reserved and have not repaired. Can control from the app. Closed app and put phone off.
Still cant add.
What network configuration in terms of HA are you referring to?
Ok .. so here is an update.
I have two of the same bulbs bought at different times.
I can pair the one but not the other.
The only difference is that the bulb that will not connect has newer firmware.
Why would that cause the light not to be found?
This is strange. Are the device ids different lengths? The firmware may be using the rare protocol version 3.2.
They are the same length
new bff984950e6a1f0e5fdwgt
old bfcd2ac2c7f2c5eec6xsn5
This does not make sense.
These are the same 22 byte length that is known to be used for protocol 3.2. But I just checked and of 4 of my devices, 3 of them use 22 byte device ids, and only one has a 20 byte id. So this does seem quite common even for protocol 3.3 devices.
Is there any info I can retrieve from tuya IOT that I can extract that will help you to understand this?
Is this perhaps using a newer protocol say like 3.4? Not sure if there is.
this is what else I’d have tried
I removed your integration and tried another local integration. Have the same issue of not being able to add device.
I repaired the bulb using the tuya app instead of the smart life one. Made no difference on yours and the other integration.
@Merril-r Using the Back button of the phone doesn't seem to close the Tuya app completely. I had to close the Tuya app from the phone's Task Manager. That's what worked for me.
@Merril-r Using the Back button of the phone doesn't seem to close the Tuya app completely. I had to close the Tuya app from the phone's Task Manager. That's what worked for me.
I logged out of the app. Still cant add device
It seems that the upstream library is in the process of adding support for protocol version 3.4, which uses a different checksum method and negotiates a session key rather than directly using the device's local key for everything.
It is possible that the newer firmware is using this new protocol version, in which case hopefully it will be able to be supported soon once the upstream support is complete.
That’s great news. Could just be the issue why my newer bulbs will not pare.
any idea when these changes will be completed?
The current main has an upgrade to tinytuya 1.7.0, which seems stable to me, and supports protocols 3.2 and 3.4 in addition to the more common 3.1 and 3.3 that have been supported before now.
@make-all I Upgraded to new version of your integration.
Still cant add the device :(
Sorry, just to confirm, you updated to "main" as I wrote above, or to the latest release 0.19.3?
@make-all I updated to the version the showed in HACS update. Do I need to download a separate version
Yes, the change to support new protocol versions is only in main, it is not yet released due to high risk of regression, so I want to test myself for at least a week. If you select "Redownload" from the tuya-local menu in HACS, then you can select among recent releases and "main". Selecting "main" will use the latest unreleased code.
@make-all
Downloaded as per above.
When I add integration the screen is mostly blank - no titles for the values must put in.
I added the values I know that must go in but still cant add device,
This is in the logs.. 2022-10-02 16:42:30.513 ERROR (SyncWorker_2) [custom_components.tuya_local - Copy.device] Failed to refresh device state for Test.
Your device id looks strange, normally it should be just hexadecimal characters (no letters above f)
@make-all
That's the ID i see under the my list of devices I have.
If I look at the info I get when I query from that device ID to get the local key there is another value:
uuid": "d9ac92e5bba59b0e"
Is that the one you are referring to?
I tried that one to,
Still will not add
Error in logs still
Logger: custom_components.tuya_local - Copy.device Source: custom_components/tuya_local - Copy/device.py:132 Integration: tuya_local - Copy First occurred: 6:31:19 AM (2 occurrences) Last logged: 6:31:57 AM
Failed to refresh device state for Test.
No, it seems I was mistaken, some device ids do end in non-hex characters. I even have 3 of these myself now that I check.
In your latest logs, the message says it is from "Integration: tuya_local - Copy". I cannot guarantee support for use of the integration with the directory name changed, Home Assistant has some implicit assumptions about directory name matching integration name.
It may also mean that you have two copies of the same integration installed which can be conflicting with each other.
@make-all
I made a copy of the original one. Let me delete that one, Redownload and try again
@make-all
Dude you are a legend :- )
Looks like HA does not like the copy I had there.
I have added four bulbs using the uuid that the status query returns.
Since this is in my Kitchen I will be able to test and monitor for you quiet a bit.
Thanks for all your effort and your patience with me, I really appreciate it
@make-all
Update from my side:
Integration seems to be stable. No errors in the logs.
What I have picked up:
The effects detected (random and colourloop) dont do anything. The following effects are detected:
- Night, Read, Meeting, Leasure, Soft, Rainbow, Shine, Beautiful, Music
When turning the lights on or off there is a delay that can be anything from 3 seconds to a minute. Sometimes the lights do not respond to a turn on or turn off - This happens as individually specified lights in an automation or using a group.
random
should be mapped to music, and colourloop
to scene, as those two are standard HA effects and seem to be the most standard on Tuya bulbs. But since there is no support for adjusting those, the best expectation for them would be that they select the most recently used scene, and last paused color from the music mode, since that seems to use the mobile mic in the Tuya App, so can't really work without it.
The other effects you have listed are specific to your light. If they are useful, support could be added by making a specific config for your bulb rather than using the generic light config it is picking up now.
The delay seems extreme - normally you should only get a 3 second delay if a command is being sent immediately after another command. It seems like the light may be going offline, either because that 3s is not long enough to avoid problems for this device (maybe using a lower powered processor than usual, or have a software bug that causes it to need longer for internal processing), or because it does not like the commands it is being sent, which could perhaps be fixed with a specific config file for this model of light.
I will check if those values are mapped when I get home.
the other affects I mentioned are part of scenes you can select and are not show stopper for me. The music mode would the one I use Most often.
The delay seems extreme - normally you should only get a 3 second delay if a command is being sent immediately after another command. It seems like the light may be going offline, either because that 3s is not long enough to avoid problems for this device (maybe using a lower powered processor than usual, or have a software bug that causes it to need longer for internal processing), or because it does not like the commands it is being sent, which could perhaps be fixed with a specific config file for this model of light.
Yes it does seem extreme. The only time I have seen that is when the lights are controlled through the Tuya app and the internet is slow.
Even controlling them as a group via the cloud and Amazon echo does not cause such a delay.
There are Four of these lights and it happens randomly between the four.
If one of the lights went offline would it not show up in the logs of the integration?
How would one setup a specific config file?
Really all that needs doing is to copy the config file that was detected when the light was added (you did not say which device it was, but maybe rgbcw_lightbulb.yaml, since the Tuya description appears to be the same) under a different name (the brand name of the bulb would be a good choice, as this seems to use unique names for its modes), and then change the color_mode mapping to list the actual dps_val values your bulb is using. Mappings can be to the same value as dps_val, they just need to be listed to appear in the list of supported effects.
random and colorloop are pre-defined effects in HA, so will probably have translations into different languages, but it is not strictly necessary to include a mapping to them if it doesn't make sense.
@make-all
where do I find this config file?
the bulb is a Vizia rgb downlighter bulb
When installed, it should be under config/custom_components/tuya_local/devices/ By default, the entity names are based on the config file name, so you should be able to work out the config name from the entity name of your lights, otherwise if you renamed them and do not remember, you can use the "Download Diagnostics" option in the device menu under Settings/Devices/Tuya local for your device, and look for the "data" section for "type".