Skip to content
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

Device is not registered in Tuya cloud #119

Open
TheMastro-11 opened this issue Mar 9, 2024 · 20 comments
Open

Device is not registered in Tuya cloud #119

TheMastro-11 opened this issue Mar 9, 2024 · 20 comments

Comments

@TheMastro-11
Copy link

What does this error mean? Because I can see the device online

@nriacr
Copy link

nriacr commented Mar 12, 2024

same issue here

@workmatic
Copy link

workmatic commented Mar 14, 2024

I was having this issue, but just solved it. As soon as I enabled a free trial of IOT Core, it registered instantly (to me it wasn't clear in any doco that this was required but I guess it is). If you get this error message and this far you at least know the tuya creds etc. are working.

To enable IOT core I did this.

Cloud > Development.
Open Project.
Authorization > Add Authorization
Find IOT core and click free trial.

Hope this helps someone

@nriacr
Copy link

nriacr commented Mar 14, 2024

Mine was already enabled, even I tried to delete old one and add authorisation again (only one auth. allowed) it didnt work for me. Thanks anyway.

@TheMastro-11
Copy link
Author

I was having this issue, but just solved it. As soon as I enabled a free trial of IOT Core, it registered instantly (to me it wasn't clear in any doco that this was required but I guess it is). If you get this error message and this far you at least know the tuya creds etc. are working.

To enable IOT core I did this.

Cloud > Development. Open Project. Authorization > Add Authorization Find IOT core and click free trial.

Hope this helps someone

Already did, nothing change. :(

@fxfitz
Copy link

fxfitz commented Mar 23, 2024

Same problem here :-(

1 similar comment
@Volo-xx
Copy link

Volo-xx commented Mar 24, 2024

Same problem here :-(

@pilonull
Copy link

Same, trying to use a SGS01 soil sensor. Have tried multiple different forks, all the same issue.

@Coder-ak
Copy link

Looks like they changed trial period and you have to update it. Go to Cloud -> Cloud Services -> IoT Core -> Subscribe to resource pack. After some time everything should work.

@AaronIsFab
Copy link

AaronIsFab commented Apr 5, 2024

Having just managed to get this going after receiving "Device is not registered in Tuya Cloud" It's not always as simple as just enabling the IoT core (Mine is already active and running until July).
I've ended up with a main build of markusg and tweaks of Kappuchino for my riecov42 additions.

But after adding these it wasn't still working, the device was recognising as "Configure" but would never see it in Tuya cloud despite showing in Cloud Explorer for "Get Device Details" on Smart Home Device Management.
image

I added some extra logger lines into cloud.py around line #166:

                    _cache[cache_key] = TuyaCloudCacheItem(api, data, {})
#        _LOGGER.debug("%s: Response", response)
        return response

    def _check_login(self) -> bool:
        cache_key = self._get_cache_key(self._data)
        return _cache.get(cache_key) != None

    async def login(self, add_to_cache: bool = False) -> dict[Any, Any]:
        return await self._login(self._data, add_to_cache)

    async def _fill_cache_item(self, item: TuyaCloudCacheItem) -> None:
        devices_response = await self._hass.async_add_executor_job(
            item.api.get,
            TUYA_API_DEVICES_URL % (item.api.token_info.uid),
        )
        
        if devices_response.get(TUYA_RESPONSE_SUCCESS):
            devices = devices_response.get(TUYA_RESPONSE_RESULT)
#            _LOGGER.debug("Successful devices for %s", devices)
            if isinstance(devices, Iterable):
                for device in devices:
#                    _LOGGER.debug("Device Loop %s", device)
                    fi_response = await self._hass.async_add_executor_job(
                        item.api.get,
                        TUYA_API_FACTORY_INFO_URL % (device.get("id")),
                    )
                    fi_response_result = fi_response.get(TUYA_RESPONSE_RESULT)
#                    _LOGGER.debug("%s :",fi_response_result)
                    if fi_response_result and len(fi_response_result) > 0:

(remove the # to enable them) which allowed me to see that I was logging in (default debug log) but not see anything in the array from the API when it looks to find the device in question.

I historically had 2 accounts registered on the Tuya App Link (one had 0 items and was before I swapped stuff from the Tuya app to SmarLife app) so i unlinked this (Be aware this page can take multiple attempts to get the data showing)
image

Deleting the extra, made it that when I re-tried, i got invalid credentials error this time which hadn't happened before.
Reset password for smartlife account, tried again and had success.

Other details:
HA Tuya is logged in via SmartLife QR code
SmartLife app is in usage on android phone
IoT Core is already active until Jul
HASS is Docker 2024.3.3

Hopefully that will help someone else narrow down their "not in cloud" issues.
image

@thkrmr
Copy link

thkrmr commented Aug 9, 2024

@AaronIsFab I followed your instructions to add debug logging, which was very helpful. Yet I wasn't able to add my device. I'm using the markusg1234 fork/branch.

Adding the BLE device, after entering my credentials, the dialog shows: "Device is not registered in Tuya cloud"

But that's not correct, the Tuya Development Platform under my Linked App Account clearly shows 1 Linked Device and it's the same I'm trying to add.

Trying to troubleshoot the situation with debug logging:
In principe the device is visible to the integration:
[custom_components.tuya_ble.cloud] Successful devices for [{'active_time': 1723172675, 'biz_type': 18, 'category': 'ggq', 'create_time': 1723172675, 'icon': 'smart/icon/ay1559701439060fw6BY/0bc4bd995df9cc19a005c78b8f5b1eca.png', 'id': 'XXX', 'ip': '', 'lat': 'XXX', 'local_key': 'XXX', 'lon': 'XXX', 'model': 'PBB A1', 'name': 'Smart Watering Timer', 'online': False, 'owner_id': 'XXX', 'product_id': '6pahkcau', 'product_name': 'Smart Watering Timer', 'status': [{'code': 'switch', 'value': False}, {'code': 'countdown', 'value': 1}, {'code': 'countdown_left', 'value': 0}, {'code': 'battery_percentage', 'value': 90}], 'sub': False, 'time_zone': '+02:00', 'uid': 'XXX', 'update_time': XXX, 'uuid': 'XXX'}]

But in practice I'm getting the error mentioned above, as if it weren't registered.

fi_response_result would return

{'code': 60009001, 'msg': 'API permission package error. For the solution, see https://developer.tuya.com/en/docs/iot/authentication-method?id=Ka49gbaxjygox.', 'success': False, 't': 1723171596964, 'tid': '98b7869c55f911ef8d1002b5f94b0719'}

I looked at the const.py as well as the Tuya developer docs, I see that the the constant for the factory info retrieval looks like TUYA_API_FACTORY_INFO_URL: Final = "/v1.0/iot-03/devices/factory-infos?device_ids=%s", API Docs say GET: /v1.0/devices/factory-infos, there's no iot-03.

It would seem that the URL changed

I've trying changing the URL to TUYA_API_FACTORY_INFO_URL: Final = "/v1.0/devices/factory-infos?device_ids=%s" removing the iot-03 part

Which seems to yield results, at least I'm getting an array from fi_response_result:
[{'id': 'XXX', 'mac': 'XX:XX:XX:XX:XX:XX', 'sn': 'XXXXXXXX', 'uuid': 'XXXXXXXX'}]

But the initial error persisted, still "Device is not registered in Tuya cloud" in the form.

I dug further, somehow the mac address was being garbled up, the final credentials array had the address stored as XX::X:X::XX::X:X: instead of 'XX:XX:XX:XX:XX:XX', I ended up discovering that TUYA_FACTORY_INFO_MAC was imported twice (line 58 of cloud.py) and also I replaced the entire join routine for the mac with:

                            # mac = ":".join(
                            #     factory_info[TUYA_FACTORY_INFO_MAC][i : i + 2]
                            #     for i in range(0, 12, 2)
                            # ).upper()
                            mac = factory_info[TUYA_FACTORY_INFO_MAC].upper()

And then I was able to add the device successfully.

Seems to me that the API changed somehow between April and now.

To sum up:

  • const.py, TUYA_API_FACTORY_INFO_URL needs to change,
  • cloud.py remove redundant declaration of TUYA_FACTORY_INFO_MAC
  • cloud.py replace the join of mac (just before item.credentials[mac]) with mac = factory_info[TUYA_FACTORY_INFO_MAC].upper()
  • Click twice on Submit

Hope this helps somebody.

@FSFirenze
Copy link

@thkrmr This totally worked, thank you! Hope it will be updated in the main build

@AaronIsFab I followed your instructions to add debug logging, which was very helpful. Yet I wasn't able to add my device. I'm using the markusg1234 fork/branch.

Adding the BLE device, after entering my credentials, the dialog shows: "Device is not registered in Tuya cloud"

But that's not correct, the Tuya Development Platform under my Linked App Account clearly shows 1 Linked Device and it's the same I'm trying to add.

Trying to troubleshoot the situation with debug logging: In principe the device is visible to the integration: [custom_components.tuya_ble.cloud] Successful devices for [{'active_time': 1723172675, 'biz_type': 18, 'category': 'ggq', 'create_time': 1723172675, 'icon': 'smart/icon/ay1559701439060fw6BY/0bc4bd995df9cc19a005c78b8f5b1eca.png', 'id': 'XXX', 'ip': '', 'lat': 'XXX', 'local_key': 'XXX', 'lon': 'XXX', 'model': 'PBB A1', 'name': 'Smart Watering Timer', 'online': False, 'owner_id': 'XXX', 'product_id': '6pahkcau', 'product_name': 'Smart Watering Timer', 'status': [{'code': 'switch', 'value': False}, {'code': 'countdown', 'value': 1}, {'code': 'countdown_left', 'value': 0}, {'code': 'battery_percentage', 'value': 90}], 'sub': False, 'time_zone': '+02:00', 'uid': 'XXX', 'update_time': XXX, 'uuid': 'XXX'}]

But in practice I'm getting the error mentioned above, as if it weren't registered.

fi_response_result would return

{'code': 60009001, 'msg': 'API permission package error. For the solution, see https://developer.tuya.com/en/docs/iot/authentication-method?id=Ka49gbaxjygox.', 'success': False, 't': 1723171596964, 'tid': '98b7869c55f911ef8d1002b5f94b0719'}

I looked at the const.py as well as the Tuya developer docs, I see that the the constant for the factory info retrieval looks like TUYA_API_FACTORY_INFO_URL: Final = "/v1.0/iot-03/devices/factory-infos?device_ids=%s", API Docs say GET: /v1.0/devices/factory-infos, there's no iot-03.

It would seem that the URL changed

I've trying changing the URL to TUYA_API_FACTORY_INFO_URL: Final = "/v1.0/devices/factory-infos?device_ids=%s" removing the iot-03 part

Which seems to yield results, at least I'm getting an array from fi_response_result: [{'id': 'XXX', 'mac': 'XX:XX:XX:XX:XX:XX', 'sn': 'XXXXXXXX', 'uuid': 'XXXXXXXX'}]

But the initial error persisted, still "Device is not registered in Tuya cloud" in the form.

I dug further, somehow the mac address was being garbled up, the final credentials array had the address stored as XX::X:X::XX::X:X: instead of 'XX:XX:XX:XX:XX:XX', I ended up discovering that TUYA_FACTORY_INFO_MAC was imported twice (line 58 of cloud.py) and also I replaced the entire join routine for the mac with:

                            # mac = ":".join(
                            #     factory_info[TUYA_FACTORY_INFO_MAC][i : i + 2]
                            #     for i in range(0, 12, 2)
                            # ).upper()
                            mac = factory_info[TUYA_FACTORY_INFO_MAC].upper()

And then I was able to add the device successfully.

Seems to me that the API changed somehow between April and now.

To sum up:

  • const.py, TUYA_API_FACTORY_INFO_URL needs to change,
  • cloud.py remove redundant declaration of TUYA_FACTORY_INFO_MAC
  • cloud.py replace the join of mac (just before item.credentials[mac]) with mac = factory_info[TUYA_FACTORY_INFO_MAC].upper()
  • Click twice on Submit

Hope this helps somebody.

@webmediart-github
Copy link

webmediart-github commented Sep 13, 2024

Update:
I now also got my trial extended (expired already in 2023) as suggested in #119 (comment) although I had to apply for extension, as a new trial "subscription to resource pack" was denied for the reason of having already applied for one in the past.
With that it actually "works" now. Only problem remaining is that all entities of my SGS01 (soil sensor) are shown as unavailable.


Below the original post.
Hi, I still face the issue of getting the error
image
in the second step of configuration.
I assume I followed all steps described in #119 (comment) and #119 (comment) correctly, as the first step is accepted and the device is showing up? In addition I added this line to the manifest.json file
"loggers": ["custom_components.tuya_ble"]
However, I don't know how or where to enable the debugging (as above is my only device, and I cant access the UI button to make use of above line) nor access the log files where these would be now captured. I am a bit stuck.
Summary of what I have/did:

  • Tuya dev cloud setup and verified that device is linked/listed
  • official Tuya integration setup in HA (logged in via SmartLife App, QR code)
  • Adjusted const.py
  • Altered cloud.py
  • Added lines to allow for debugging (logger) to both cloud.py and manifest.json
  • Restarted HA

Hope someone is able to provide some further guidance. Thank you!

@FSFirenze
Copy link

FSFirenze commented Sep 13, 2024 via email

@webmediart-github
Copy link

I think I might lack a bit of general "Tuya" knowledge, but are you able to describe the detailed steps how you setup the device itself? I went like this:

  1. Open SmartLife App and add device for tuya cloud connection
  2. Reset Device to disconnect from phone via reset button

Although it shows now in HA, I suspect that it is not connected to HA via bluetooth as its entities are unavailable?

Same challenges, however started working for me when I delete everything on tiya cloud and started from scratch with a new email address (blessed be the dot trick on gmail accounts)

@FSFirenze
Copy link

FSFirenze commented Sep 14, 2024 via email

@jantoretelnes
Copy link

After inserting the following code in devices.py i can see my sensors. Seems my SGS01 sensors have a different category and product.

Inserted the code at around line 287.

    "zwjcy": TuyaBLECategoryInfo(
        products={
            "gvygg3m8": TuyaBLEProductInfo(  # device product_id
                name="Soil moisture sensor - test",
            ),
        },
    ),

@Zebsi235
Copy link

Zebsi235 commented Sep 25, 2024

I was searching for a solution for this problem and tried different options from this issue.
I added the category and product IDs to the devices.py file so I could discover the devices. Then the problem with tuya cloud occured.
I refreshed my IOT Core Subscription for free for another 6 months but still the same problem.

Now I got it working! The problem was the App that I used for connecting the sensors. I used Smart Life becuase I used it for all my tuya devices (which also connected to HA).
Turns out you need to connect them through the tuya app itself. Now it works flawlessly.
Simple solution but I didn't expect that. Hope it helps someone!

@Moe555
Copy link

Moe555 commented Oct 19, 2024

Hi,

Thanks for all the input provided here, much appreciated!
But even after following all steps mentioned here and elsewhere, besides starting all over from scratch on the Tuya-side,
I still can't control my BLE Fingerbot via HA anymore.

Meanwhile the device is at least showing up, also containing all necessary entities,
but they are all disabled and the device is "unavailable".
Also in the Tuya Cloud it's always shown as offline and is not actually controllable.
(And when I try to delete it in HA nothing happens...this integration is so broken... :( )

But this is the same for most of my devices (besides one all are offline in the cloud) and they are all working fine in HA.
(E.g. a SGS Plant sensor, which despite of being offline in the Tuya Cloud just popped up in HA,
even if I'm actually not caring about that one at all D)

Via the App the Fingerbot is working fine and can be controlled
(I had it paired to both apps already one after the other, both are working fine).

I did all changes mentioned here, also the necessary "riecov42"/"kg" additions as usual, but it's still not working.
I can provide screenshots or logs if necessary.
Any hints are welcome.
Thanks

@thkrmr
Copy link

thkrmr commented Oct 19, 2024

@Moe555 I had issues with devices showing as unavailable, when two things were out of whack:
a) bad range, device too far away from the BT proxy
b) BT proxies didn't add properly to Home Assistant, meaning the proxies were visible in the ESPHome interface (where you change the build config), but the proxies weren't properly added to the HA device list as entities under the Settings - Devices and Services - ESPHome, as an ESPHome device with bt proxy functionality. I ended up deleting all entries and flashing the ESPs anew and adding the 'new' proxies to HA. Within the esphome yaml configs, I turned on verbose logging.

So I fixed the range issue by placing the proxy close and subsequently fixed the ESPHome BT proxy issues.

Now when I check the ESPHome log (wirelessly) of a particular proxy, I see in the logs that BLE packets are being proxied. This correlates with my Tuya BLE devices working quite stable. When this all wasn't working well, I had no log entries of proxied BLE packets. I also turned off BT on my machine completely, all BT communication for Tuya BLE is done via the ESPHome BT proxies. I initially used Wemos D1 mini boards and the switched to M5Stack ATOMS3 Lite boards. The BT proxies are also proxying SwitchBot Curtain motors in parallel to the Tuya BLE bits without a hitch.

Your mileage may vary, but I had pretty good success with this setup, surviving updates to HA, updates to ESPHome and even the switch from Wemos to M5Stack.

Good luck.

@Moe555
Copy link

Moe555 commented Oct 21, 2024

@thkrmr Thanks for the detailed explanation.
I can't imagine that it's a range issue, since it's sitting next to the raspi HA host.
Also placing it next to a BT proxy doesn't change anything unfortunately.
The proxy is properly configured imo. Other sensor values, etc. get relayed w/o issues.

Besides that, other Tuya BLE devices (like a plant sensor) are shown offline in the Tuya Cloud as well,
but are working perfectly fine in HA.
It's really confusing...

I guess I messed something up during all the manual modifications which are necessary,
since this integration is not updated or maybe because something was changed on the Tuya side/is not configured properly.
But I double-checked everything and still see no mistake.
As mentioned here it would be really great if there would be at least some working "baseline" again to start with, which is just not the case at the moment, at least for those Fingerbots.

BR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests