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

Error after updating to Home Assistant 2024.2.0 update #111

Closed
JanOstrowka opened this issue Feb 7, 2024 · 40 comments
Closed

Error after updating to Home Assistant 2024.2.0 update #111

JanOstrowka opened this issue Feb 7, 2024 · 40 comments

Comments

@JanOstrowka
Copy link

Description

After updating to the latest Home Assistant version, my Tuya BLE custom integration started throwing an import error on startup. Specifically, there is a failure importing CONF_ACCESS_ID from homeassistant.components.tuya.const.

Log details

Logger: homeassistant.setup
Source: setup.py:251
First occurred: 10:42:15 PM (1 occurrences)
Last logged: 10:42:15 PM

Setup failed for custom integration 'tuya_ble': Unable to import component: cannot import name 'CONF_ACCESS_ID' from 'homeassistant.components.tuya.const' (/usr/src/homeassistant/homeassistant/components/tuya/const.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 827, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/tuya_ble/__init__.py", line 17, in <module>
    from .cloud import HASSTuyaBLEDeviceManager
  File "/config/custom_components/tuya_ble/cloud.py", line 18, in <module>
    from homeassistant.components.tuya.const import (
ImportError: cannot import name 'CONF_ACCESS_ID' from 'homeassistant.components.tuya.const' (/usr/src/homeassistant/homeassistant/components/tuya/const.py)
@stevewrightnz
Copy link

And here!

Logger: homeassistant.config_entries
Source: config_entries.py:2247
First occurred: 11:29:28 AM (1 occurrences)
Last logged: 11:29:28 AM

Error occurred loading flow for integration tuya_ble: cannot import name 'CONF_ACCESS_ID' from 'homeassistant.components.tuya.const' (/usr/src/homeassistant/homeassistant/components/tuya/const.py)

@mikekornikh
Copy link

Yeah, I came here to say the same thing

@liouma
Copy link

liouma commented Feb 8, 2024

Same issue here.

@Chreece
Copy link

Chreece commented Feb 8, 2024

There is a new code for Tuya integration. Some changes made that removed the const "CONF_ACCESS_ID" from:
https://github.com/home-assistant/core/blob/dev/homeassistant/components/tuya/const.py

What changes should be made by tuyable is unknown to me...

@noy1122
Copy link

noy1122 commented Feb 8, 2024

Same issue here.

@Chreece
Copy link

Chreece commented Feb 8, 2024

Guys, commenting "same issue here" isn't really helpful... This is a general issue that caused the integration to stop working. It's the same for everyone

@carferrer
Copy link

I have try to install a version of TUYA before 2024.2.0 as custom_componentes but still nos working. I'll keep trying.

@reversehaven
Copy link

I rolled back the update. I'm currently on 2024.1.6. rather than 2024.2.0 The good news is that my tuya_ble is working again. I realise it's something to do with the fact that the tuya integration now uses a different method to log in. Rather than needing a stupid developer account, they now sync directly to smartlife app, so the login credentials are now changed.

https://www.home-assistant.io/blog/2024/02/07/release-20242/#backward-incompatible-changes

However, the downside is that tuya_ble isn't maintained and the constants CONF_Access_ID and CONF_Access_Secret are now deprecated. You now need to remove them from the script which is easy, just go through all the .py and remove all instances of them. Now the problem comes I think where they need new login credentials, I have no idea how to see the tuya integration's code and see how it extracts those credentials. Likely once you've identified it, it's copypaste work.

@ppcsite
Copy link

ppcsite commented Feb 9, 2024

I was able to fix mine, you can take a look here:
#112 (comment)

@mimikm
Copy link

mimikm commented Feb 9, 2024

I was able to fix mine, you can take a look here: #112 (comment)

Good work, I still have problem installing with message:
Config flow could not be loaded: {"message":"Invalid handler specified"}

and logs:

`Logger: homeassistant.config_entries
Source: config_entries.py:2247
First occurred: 05:03:10 (9 occurrences)
Last logged: 09:42:50

Error occurred loading flow for integration tuya_ble: cannot import name 'CONF_ACCESS_ID' from 'homeassistant.components.tuya.const' (/usr/src/homeassistant/homeassistant/components/tuya/const.py)
Error occurred loading flow for integration tuya_ble: cannot import name 'CONF_COUNTRY_CODE' from 'homeassistant.components.tuya.const' (/usr/src/homeassistant/homeassistant/components/tuya/const.py)`

@Chreece
Copy link

Chreece commented Feb 9, 2024

I was able to fix mine, you can take a look here: #112 (comment)

Yes you almost did it! The next thing you should look on is the CONF_COUNTRY_CODE, which is also removed from tuya/const

@JanOstrowka
Copy link
Author

Thank you everyone, especially @ppcsite & @Chreece , your suggestions revived my Fingerbot back from the dead!

For Anyone curious what's the fix, this it it:

  1. edit const.py by adding those
CONF_AUTH_TYPE = "auth_type"
CONF_PROJECT_TYPE = "tuya_project_type"
CONF_ENDPOINT = "endpoint"
CONF_ACCESS_ID = "access_id"
CONF_ACCESS_SECRET = "access_secret"
SMARTLIFE_APP = "smartlife"
TUYA_SMART_APP = "tuyaSmart"

  1. edit config_flow.py by making sure those sections look like as follow
from homeassistant.const import (
    CONF_ADDRESS,
    CONF_COUNTRY_CODE,
    CONF_PASSWORD,
    CONF_USERNAME,
)
from homeassistant.components.tuya.const import (
    CONF_APP_TYPE,
    CONF_ENDPOINT,
    TUYA_RESPONSE_CODE,
    TUYA_RESPONSE_MSG,
    TUYA_RESPONSE_SUCCESS,
)
from .const import (
    DOMAIN,
    CONF_ACCESS_ID,
    CONF_ACCESS_SECRET,
    CONF_AUTH_TYPE,
    SMARTLIFE_APP,
    TUYA_SMART_APP,
)

  1. edit cloud.py sections below to look the same
from homeassistant.const import (
    CONF_ADDRESS,
    CONF_COUNTRY_CODE,
    CONF_DEVICE_ID,
    CONF_PASSWORD,
    CONF_USERNAME,
)
from homeassistant.components.tuya.const import (
    CONF_APP_TYPE,
    CONF_ENDPOINT,
    DOMAIN as TUYA_DOMAIN,
    TUYA_RESPONSE_RESULT,
    TUYA_RESPONSE_SUCCESS,
)
from .const import (
    CONF_PRODUCT_MODEL,
    CONF_UUID,
    CONF_LOCAL_KEY,
    CONF_CATEGORY,
    CONF_PRODUCT_ID,
    CONF_DEVICE_NAME,
    CONF_PRODUCT_NAME,
    DOMAIN,
    TUYA_API_DEVICES_URL,
    TUYA_API_FACTORY_INFO_URL,
    TUYA_FACTORY_INFO_MAC,
    TUYA_API_DEVICES_URL,
    TUYA_API_FACTORY_INFO_URL,
    TUYA_FACTORY_INFO_MAC,
    CONF_ACCESS_ID,
    CONF_ACCESS_SECRET,
    CONF_AUTH_TYPE,
    SMARTLIFE_APP,
)

@mimikm
Copy link

mimikm commented Feb 9, 2024

Fantastic work. I have problem as follows:
when installing I get: Error Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble

logs:
This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/tuya_ble/config_flow.py:134
Integration: Tuya BLE
First occurred: 10:39:53 (1 occurrences)
Last logged: 10:39:53

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/discovery_flow.py", line 96, in async_start
await gather_with_limited_concurrency(
File "/usr/src/homeassistant/homeassistant/util/async
.py", line 188, in gather_with_limited_concurrency
return await gather(
^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/async_.py", line 186, in sem_task
return await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 945, in async_init
flow, result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 973, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 501, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tuya_ble/config_flow.py", line 239, in async_step_bluetooth
return await self.async_step_login()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tuya_ble/config_flow.py", line 282, in async_step_login
return _show_login_form(self, user_input, errors, placeholders)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tuya_ble/config_flow.py", line 134, in _show_login_form
[country.name for country in TUYA_COUNTRIES]
^^^^^^^^^^^^^^
NameError: name 'TUYA_COUNTRIES' is not defined

@Chreece
Copy link

Chreece commented Feb 9, 2024

"/config/custom_components/tuya_ble/config_flow.py", line 134, in _show_login_form [country.name for country in TUYA_COUNTRIES] ^^^^^^^^^^^^^^ NameError: name 'TUYA_COUNTRIES' is not defined

recheck your changes, you haven't done everything as it should... TUYA_COUNTRIES shouldn't exist

@mimikm
Copy link

mimikm commented Feb 9, 2024

"/config/custom_components/tuya_ble/config_flow.py", line 134, in _show_login_form [country.name for country in TUYA_COUNTRIES] ^^^^^^^^^^^^^^ NameError: name 'TUYA_COUNTRIES' is not defined

recheck your changes, you haven't done everything as it should... TUYA_COUNTRIES shouldn't exist

Changes checked, but TUYA_COUNTRIES exists in config flow later in code I think.

@reversehaven
Copy link

I super appreciate all you awesome folks, my smart lock is working beautifully once again.

@scrampker
Copy link

"/config/custom_components/tuya_ble/config_flow.py", line 134, in _show_login_form [country.name for country in TUYA_COUNTRIES] ^^^^^^^^^^^^^^ NameError: name 'TUYA_COUNTRIES' is not defined

recheck your changes, you haven't done everything as it should... TUYA_COUNTRIES shouldn't exist

Changes checked, but TUYA_COUNTRIES exists in config flow later in code I think.

Yep, I have it in 3 places. Maybe someone can post a link to the full file contents for the 3 mentioned above? Copy and replace the entire shebang.

@mimikm
Copy link

mimikm commented Feb 9, 2024

"/config/custom_components/tuya_ble/config_flow.py", line 134, in _show_login_form [country.name for country in TUYA_COUNTRIES] ^^^^^^^^^^^^^^ NameError: name 'TUYA_COUNTRIES' is not defined

recheck your changes, you haven't done everything as it should... TUYA_COUNTRIES shouldn't exist

Changes checked, but TUYA_COUNTRIES exists in config flow later in code I think.

Yep, I have it in 3 places. Maybe someone can post a link to the full file contents for the 3 mentioned above? Copy and replace the entire shebang.

I have overcome this by removing integration and downloading it completely from: GITHUB REPO, It must have been other changes to other files previously.

@scrampker
Copy link

"/config/custom_components/tuya_ble/config_flow.py", line 134, in _show_login_form [country.name for country in TUYA_COUNTRIES] ^^^^^^^^^^^^^^ NameError: name 'TUYA_COUNTRIES' is not defined

recheck your changes, you haven't done everything as it should... TUYA_COUNTRIES shouldn't exist

Changes checked, but TUYA_COUNTRIES exists in config flow later in code I think.

Yep, I have it in 3 places. Maybe someone can post a link to the full file contents for the 3 mentioned above? Copy and replace the entire shebang.

I have overcome this by removing integration and downloading it completely from: GITHUB REPO, It must have been other changes to other files previously.

@mimikm what's the best way to use the github repo directly? I find it super annoying to navigate the actual file system to do a git clone.

@mimikm
Copy link

mimikm commented Feb 9, 2024

@scrampker in hacs in top right corner are three dots. There you can add custom repository. Place link I have attached and add. Then tuya_ble will be available in hacs to add.

@scrampker
Copy link

Ah, thanks, I actually didn't notice it was a different project entirely. Though does get a bit messy since it's named exactly the same. Anyhow I'm sure the main issue will get resolved, but I'll give this a go for now.

Much appreciated.

@mimikm
Copy link

mimikm commented Feb 9, 2024

@scrampker main repository is not supported anymore.

@scrampker
Copy link

Gotcha, well the repo you listed does work, but despite my lock being specifically listed (ludzroix) all it can do is see if the motor state is on or off (lock/unlock.) No control. Guess I'm back to the drawing board.

@titou4307
Copy link

Hello
I have follow the modifications all files and the integration BLE will function ...
So many thanks for the works of the contributors (sorry for my french and my poor english...)

I am trying to add a new device in Tuya BLE but it was asked for :
COUNTRY
Tuya Iot Access ID
Tuya Iot Access Secret
Account
Password

But after typing this 5 data, the error message is :

No unconfigured devices found.

But this battery is in the cloud (visible under tuya app)

I have other battery appears....and in the Tuya BLE that I have added there is many week
If I click on configure so I have a message :

Device is not registered in Tuya cloud

@stevewrightnz
Copy link

removed the duplicates from

from .const import (
CONF_PRODUCT_MODEL,
CONF_UUID,
CONF_LOCAL_KEY,
CONF_CATEGORY,
CONF_PRODUCT_ID,
CONF_DEVICE_NAME,
CONF_PRODUCT_NAME,
DOMAIN,
TUYA_API_DEVICES_URL,
TUYA_API_FACTORY_INFO_URL,
TUYA_FACTORY_INFO_MAC,
TUYA_API_DEVICES_URL,
TUYA_API_FACTORY_INFO_URL,
TUYA_FACTORY_INFO_MAC,

CONF_ACCESS_ID,
CONF_ACCESS_SECRET,
CONF_AUTH_TYPE,
)

and all works again!

SteveW

@mikekornikh
Copy link

Thank you everyone, especially @ppcsite & @Chreece , your suggestions revived my Fingerbot back from the dead!

For Anyone curious what's the fix, this it it:

  1. edit const.py by adding those
CONF_AUTH_TYPE = "auth_type"
CONF_PROJECT_TYPE = "tuya_project_type"
CONF_ENDPOINT = "endpoint"
CONF_ACCESS_ID = "access_id"
CONF_ACCESS_SECRET = "access_secret"
SMARTLIFE_APP = "smartlife"
TUYA_SMART_APP = "tuyaSmart"
  1. edit config_flow.py by making sure those sections look like as follow
from homeassistant.const import (
    CONF_ADDRESS,
    CONF_COUNTRY_CODE,
    CONF_PASSWORD,
    CONF_USERNAME,
)
from homeassistant.components.tuya.const import (
    CONF_APP_TYPE,
    CONF_ENDPOINT,
    TUYA_RESPONSE_CODE,
    TUYA_RESPONSE_MSG,
    TUYA_RESPONSE_SUCCESS,
)
from .const import (
    DOMAIN,
    CONF_ACCESS_ID,
    CONF_ACCESS_SECRET,
    CONF_AUTH_TYPE,
    SMARTLIFE_APP,
    TUYA_SMART_APP,
)
  1. edit cloud.py sections below to look the same
from homeassistant.const import (
    CONF_ADDRESS,
    CONF_COUNTRY_CODE,
    CONF_DEVICE_ID,
    CONF_PASSWORD,
    CONF_USERNAME,
)
from homeassistant.components.tuya.const import (
    CONF_APP_TYPE,
    CONF_ENDPOINT,
    DOMAIN as TUYA_DOMAIN,
    TUYA_RESPONSE_RESULT,
    TUYA_RESPONSE_SUCCESS,
)
from .const import (
    CONF_PRODUCT_MODEL,
    CONF_UUID,
    CONF_LOCAL_KEY,
    CONF_CATEGORY,
    CONF_PRODUCT_ID,
    CONF_DEVICE_NAME,
    CONF_PRODUCT_NAME,
    DOMAIN,
    TUYA_API_DEVICES_URL,
    TUYA_API_FACTORY_INFO_URL,
    TUYA_FACTORY_INFO_MAC,
    TUYA_API_DEVICES_URL,
    TUYA_API_FACTORY_INFO_URL,
    TUYA_FACTORY_INFO_MAC,
    CONF_ACCESS_ID,
    CONF_ACCESS_SECRET,
    CONF_AUTH_TYPE,
    SMARTLIFE_APP,
)

Fixed it for me. You're amazing!

@liouma
Copy link

liouma commented Feb 10, 2024

Thanks for the synthesis ikekornikh!
I followed your instructions and I confirm it work for me too :)

@IamMattM
Copy link

@mikekornikh
Great instructions. Confirmed working again as well.
Thanks.

@e10kstarfire
Copy link

I have overcome this by removing integration and downloading it completely from: GITHUB REPO, It must have been other changes to other files previously.

Any idea who setup this new repo and if it will be maintained going forward? Thanks.

JanOstrowka added a commit to JanOstrowka/tuya-ble that referenced this issue Feb 12, 2024
JanOstrowka added a commit to JanOstrowka/tuya-ble that referenced this issue Feb 12, 2024
JanOstrowka added a commit to JanOstrowka/tuya-ble that referenced this issue Feb 12, 2024
@titou4307
Copy link

titou4307 commented Feb 12, 2024

Hello
For all who have mod all the files, does it possible to had a new BLE Tuya device or not ?

My proxy bluetooth find new device BLE and it wa registered in to the cloud (with Tuya App)
But when I want to add this and after type all info (region, ID and other account...) I stay with the error (Tuya is not registered in the cloud....

May be I must rolled back the update to 2024.1.6. appaired the new device and then reupdate to 2024.2.0 ??

Thanks for your helps

@IamMattM
Copy link

IamMattM commented Feb 12, 2024

Hello For all who have mod all the files, does it possible to had a new BLE Tuya device or not ?

My proxy bluetooth find new device BLE and it wa registered in to the cloud (with Tuya App) But when I want to add this and after type all info (region, ID and other account...) I stay with the error (Tuya is not registered in the cloud....

May be I must rolled back the update to 2024.1.6. appaired the new device and then reupdate to 2024.2.0 ??

Thanks for your helps

@titou4307
When I had this problem the last time it was because within the Tuya IOT platform, the "IOT Core" service needed to be applied for and/or had expired to register new devices:
https://community.home-assistant.io/t/other-options-when-tuya-iot-expired/542767

image

@k2dp2k
Copy link

k2dp2k commented Feb 17, 2024

@JanOstrowka still not working with your repo.... also the ne fingerbot category kg is missing....

@JanOstrowka
Copy link
Author

@JanOstrowka still not working with your repo.... also the ne fingerbot category kg is missing....

Sorry, I should have added a disclaimer to the repository. It's a work in progress and unfortunately it doesn't work at the moment

@Moe555
Copy link

Moe555 commented Feb 19, 2024

Hey switching to this fork changed my integration setup error from
Error Config flow could not be loaded: {"message":"Invalid handler specified"
to
Error Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble
nice!

Just kidding...Thanks for picking this one up and also thanks to the original dev :)👍
Looking forward to a fix which will actually let me use this integration for the first time (on HA 2024.2.2) :D

@ShonP40
Copy link

ShonP40 commented Feb 19, 2024

Has anyone else been getting no unconfigured devices found ?

@andraslesko93
Copy link

I also have the same issue :(

@titou4307
Copy link

Me too...

@Moe555
Copy link

Moe555 commented Feb 19, 2024

See #105 (comment)
Maybe it helps you as well.

@ShonP40
Copy link

ShonP40 commented Feb 19, 2024

That's what I'm using.
Any other version just errors with invalid config flow

@andraslesko93
Copy link

I managed to solve the "no unconfigured devices found" issue. Somehow the devices got disabled... perhaps HA disabled it after the integration broke. I simply re-enabled it on the UI, now it's working again.

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