PlusPlus-ua / ha_tuya_ble

Home Assistant support for Tuya BLE devices
MIT License
183 stars 128 forks source link

Device is not registered in Tuya cloud #119

Open TheMastro-11 opened 6 months ago

TheMastro-11 commented 6 months ago

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

nriacr commented 6 months ago

same issue here

workmatic commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

Same problem here :-(

Volo-xx commented 6 months ago

Same problem here :-(

pilonull commented 6 months ago

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

Coder-ak commented 6 months ago

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 commented 6 months ago

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 commented 1 month ago

@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:

Hope this helps somebody.

FSFirenze commented 3 weeks ago

@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_INFOURL needs to change,
  • cloud.py remove redundant declaration of _TUYA_FACTORY_INFOMAC
  • 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 commented 2 weeks ago

Update: I now also got my trial extended (expired already in 2023) as suggested in https://github.com/PlusPlus-ua/ha_tuya_ble/issues/119#issuecomment-2027186605 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 https://github.com/PlusPlus-ua/ha_tuya_ble/issues/119#issuecomment-2039869993 and https://github.com/PlusPlus-ua/ha_tuya_ble/issues/119#issuecomment-2277086223 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:

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

FSFirenze commented 2 weeks ago

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)

On Fri, Sep 13, 2024 at 4:08 PM webmediart-github @.***> wrote:

Hi, I still face the issue of getting the error image.png (view on web) https://github.com/user-attachments/assets/152f631b-34ac-4156-a4ad-227a80a34ff2 in the second step of configuration. I assume I followed all steps described in #119 (comment) https://github.com/PlusPlus-ua/ha_tuya_ble/issues/119#issuecomment-2039869993 and #119 (comment) https://github.com/PlusPlus-ua/ha_tuya_ble/issues/119#issuecomment-2277086223 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!

— Reply to this email directly, view it on GitHub https://github.com/PlusPlus-ua/ha_tuya_ble/issues/119#issuecomment-2350210460, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCZLFJTP76QOVDEA6YLMYIDZWNH3XAVCNFSM6AAAAABEOIHZHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJQGIYTANBWGA . You are receiving this because you commented.Message ID: @.***>

webmediart-github commented 2 weeks ago

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 commented 2 weeks ago

If it shows in HA and you have no entities (or in my case just the signal entity), then it is likely that your tuta product isn’t supported yet. Every tuta product seems to have a category ID and a Product ID, you’ll find them in one of the .py files (I think the devices.py). If your isn’t there then you are out of luck (like me).

The developers of this integration seem to have disappeared recently, there are a few forks but they don’t seem active either.

Theoretically it isn’t too difficult to add if you have category ID, Product ID but I got into a few issues and I have an open ask for someone better than me to support.

Sorry I can’t help much more

On Fri, Sep 13, 2024 at 4:55 PM webmediart-github @.***> wrote:

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)

— Reply to this email directly, view it on GitHub https://github.com/PlusPlus-ua/ha_tuya_ble/issues/119#issuecomment-2350394609, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCZLFJTV5FFAWZWXL2I75JDZWNNNJAVCNFSM6AAAAABEOIHZHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJQGM4TINRQHE . You are receiving this because you commented.Message ID: @.***>

jantoretelnes commented 1 week ago

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 commented 1 week ago

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!