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

Tuya credential steps unclear and not easy to reconfigure #8

Open
BrendanxP opened this issue Dec 22, 2024 · 6 comments
Open

Tuya credential steps unclear and not easy to reconfigure #8

BrendanxP opened this issue Dec 22, 2024 · 6 comments

Comments

@BrendanxP
Copy link

BrendanxP commented Dec 22, 2024

After updating to 1.16 to fix the login issues, and tweaking the frida command to obtain the local key, I am now stuck at successfully making the tuya connection to the device. It is also not easy to play around with the inputs, as all 5 fields need to be submitted, and when it does not work, the entire integration entry needs to be removed and with all 5 fields resubmitted.

I will split the issue into 4 parts:

  1. Updating entries: Currently, when making a mistake in the config, it cannot be updated as the integration entry need to be deleted and re-entered. Many integrations have a reconfigure option (one example of this is AfvalInfo). Since all 5 fields need to be re-entered and it needs to establish the connection to the server, this is very cumbersome when troubleshooting.

  2. Client_id (readme) / tuya_client_id (set-up): The naming is inconsistent and it is a bit vague what roll tuya plays in this setup, as we do not have to touch the tuya app, right? Moreover, it could be specified that this is the DeviceID under: the app dashboard, appliances, pet feeder, settings, DeviceID. And specify this is NOT the same as the HomeID. (Am I correct here??)

  3. IP (readme) / tuya_ip (setup): Again the naming is confusing, I would call it Pet Feeder IP. Moreover, what is the best way to find it? I cannot seem to find it in the app, and in my Asus router it does not show up with any name as it is listed as an unknown manufacturer. What I did was export at the devices list under 2.4Ghz, then turn off the WiFi by unplugging the power and wait for a bit, look again at the list and see what changed. Then I turned on the WiFi again by plugging it back in and have it appear again. Was this the easiest method, or are there any alternatives? With my crowded network this is not as simple as it may seem to others.

  4. Local Key (readme) / tuya_local_key (setup): Again for the naming I would stick to Local Key. Additionally, the formatting from the obtained output.txt file is confusing and it is unclear what to use as an input here.
    For example, my output looks like "localKey\":\"FceXXXX]+$7}9Zl.\",, now what part do I take: \"FceXXXX]+$7}9Zl.\", "FceXXXX]+$7}9Zl.\", FceXXXX]+$7}9Zl.\, or FceXXXX]+$7}9Zl.?

Since I have numerous unknowns, I tried multiple combinations but could not get it to work yet. This could be from any simple reason such as needing to take a different value for Client_id, accidentally still having selected the wrong IP, or wrong formatting on the LocalKey. If someone could clear up some of the unknowns will become much easier to troubleshoot a single value rather than all three.

@AboveColin
Copy link
Owner

AboveColin commented Dec 23, 2024

Thanks for the feedback! I'll look into everything the coming days

@AboveColin
Copy link
Owner

Also, And specify this is NOT the same as the HomeID. (Am I correct here??) Where do you see HomeID? I can't seem to find a HomeID anywhere

@BrendanxP
Copy link
Author

Also, And specify this is NOT the same as the HomeID. (Am I correct here??) Where do you see HomeID? I can't seem to find a HomeID anywhere

@AboveColin Thanks for large efforts with this integration and adressing the issues!

By accidentally I stumbled upon the homeID first, before seeing the deviceID, so that is why I mentioned it.
The HomeID is found in the app under profile, home management, "your home name", Home ID.

@AboveColin
Copy link
Owner

Also, And specify this is NOT the same as the HomeID. (Am I correct here??) Where do you see HomeID? I can't seem to find a HomeID anywhere

@AboveColin Thanks for large efforts with this integration and adressing the issues!

By accidentally I stumbled upon the homeID first, before seeing the deviceID, so that is why I mentioned it. The HomeID is found in the app under profile, home management, "your home name", Home ID.

I updated the readme, should be more clear now :)
Also improved the consistency of words in the setup/readme and it's possible to reconfigure now 😁

@BrendanxP
Copy link
Author

I updated the readme, should be more clear now :) Also improved the consistency of words in the setup/readme and it's possible to reconfigure now 😁

Thats incredibly fast work. I will try it out right away, amazing!

@BrendanxP
Copy link
Author

BrendanxP commented Dec 23, 2024

I updated to the 1.71 and followed the improved guidelines in the readme but unfortunately still cannot seem to get it working.
I had the server based items working using the two tokens and tried the new recofigure part. The thing I noticed immediately is that it would be of great benefit if we could opt to recofingure the cloud or the local part seperately, because now I still had to get new access+refresh tokens. Similarly, when those tokens expire (which the application console says is within 2 weeks), we would not want to reconfigure the local parts as well.
Anyway, after getting the new tokens and filling out all the field, I got an error while reconfiguring. Next up, I removed the entire entry again and tried to resubmit everything and also got the same error: Unknown error occurred. Any chance the new update caused this?
Even when only filling out the access+refresh tokens and leaving the other fields blank it does not work anymore, while it did work a moment ago. I am getting a bit lost at this point.

Schermafbeelding 2024-12-23 222631

`Logger: aiohttp.server
Source: /usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py:451
First occurred: 11:25:00 PM (5 occurrences)
Last logged: 11:39:10 PM

Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py", line 480, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_app.py", line 569, in _handle
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 86, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
return await super().post(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
return await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
result = await self._flow_mgr.async_configure(flow_id, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in async_configure
result = await self._async_configure(flow_id, user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 414, in _async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
flow, cur_step["step_id"], user_input
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 517, in _async_handle_step
result: _FlowResultT = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/philips_pet_series/config_flow.py", line 210, in async_step_reconfigure
self.hass.config_entries.async_update_entry(self.entry, data=user_input)
^^^^^^^^^^
AttributeError: 'ConfigFlow' object has no attribute 'entry'`

Schermafbeelding 2024-12-23 223113

`Logger: homeassistant.config_entries
Source: config_entries.py:640
First occurred: 11:28:54 PM (2 occurrences)
Last logged: 11:40:15 PM

Error setting up entry Philips Pets Series (My Name) for philips_pet_series
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 640, in __async_setup_with_context
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/philips_pet_series/init.py", line 187, in async_setup_entry
await coordinator.async_config_entry_first_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 306, in async_config_entry_first_refresh
await self._async_refresh(
log_failures=False, raise_on_auth_failed=True, raise_on_entry_error=True
)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 379, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/philips_pet_series/init.py", line 125, in _async_update_data
tuya_status = await asyncio.to_thread(self._client.get_tuya_status)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/asyncio/threads.py", line 25, in to_thread
return await loop.run_in_executor(None, func_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError`

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

2 participants