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

can not connect to Device #34

Closed
Heiner1967 opened this issue Sep 27, 2021 · 32 comments
Closed

can not connect to Device #34

Heiner1967 opened this issue Sep 27, 2021 · 32 comments

Comments

@Heiner1967
Copy link

Heiner1967 commented Sep 27, 2021

Hi, I have some trouble with Tuya as well as with Tuya Cloud. Likly due to all this ID I strugle to use the right one.

in Tuya IOT Platform I am able to link to my Tuya App, which is afterwards visible from both ends ( IOT Platform as well as inside the App) as a result I can see a UID inside IOT Platform

However I am not able to see the Device which is visible and function with no problem inside Tuya App. I guess here is already the Error.
Inside the Tuya App there is a Virtuell-ID, and IP, a MAC and the TimeZone Europe/Berlin.
Inside IOT Patform the Device Management is on Western Europe ( after adding Central Europe the Device is visible inside IOT Platform)

in fhem tuya_system shows "ready" but no device is found
likly the DeviceID used is wrong, it is neither the Virtual ID inside the Tuya App, nor the UID of the linked Tuya App.

In the individual Device setup I struggle to identify the Product-ID and I do not get the difference of DEVICE_ID and LOCAL_KEY

Now i struggle to see what to do next.

I hope you have a hint for me. Many Thanks.

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

Hi,
do you see the added device in the iot platform? If so, please post the define of your tuya_cloud setup device (please remove the password).

@Heiner1967
Copy link
Author

Yes I see it:

Device Name Device ID Product Association Online Status Activation Time Operation
Elitecho-GU10 5.5W RGBCCT W 150028062cf432edf33a Elitecho-GU10 5.5W RGBCCT W x.y@z.com Online 2021-09-06 20:10:18 Debug Device

In fhem I tried to define with this:
tuya 150028062cf432edf33a 150028062cf432edf33a 217.254.242.5 150028062cf432edf33a 3.32 AccessID AccessSecret

The IP I got from the Tuya App, suprisinlgy different to the rest of my Homenetwork IP

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

Btw, you should use only tuya_cloud. I wouldn't recommend tuya module as it is not event based and therefore doesn't readings aren't updated immediately.

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

Please use tuya_cloud instead of tuya module.

@Heiner1967
Copy link
Author

May be worth to mention the Tuya
-system DeviceID is mention as 0 !!!! I used in the definition the UID of the Tuya Appl link, same result I get if I use the Device ID as per last post....

I guess here is something wrong and hence the scan is not working

@Heiner1967
Copy link
Author

Heiner1967 commented Sep 27, 2021

ok, Cloud connector is defined with:
tuya_cloud setup vAccessID AcessSecret Username Passwort tuyaSmart Europe

By the way a change or delete and new install seems to be super qucik, only intial definition took a little longer, no clue iof it realy tries modifications to apply

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

Yes, what's the result?

@Heiner1967
Copy link
Author

Heiner1967 commented Sep 27, 2021

failed to connect.

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

Please just do a define of tuya_cloud setup ...

Post the log output and the readings. If you get failed to connect, you need to check the clientid, secret, username and password again.

@Heiner1967
Copy link
Author

just deleted all tuya Module related.
I go to verbose 5. The Log says:
`2021-09-27 22:34:54,880 - ERROR - fhempy.lib.fhem_pythonbinding: Failed to handle message:
Traceback (most recent call last):
File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py", line 389, in _onMessage
await self.sendBackReturn(hash, ret)
File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py", line 95, in sendBackReturn
await self.wsconnection.send(msg.encode("utf-8"))
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 631, in send
await self.write_frame(True, opcode, data)
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 1188, in write_frame
await self.drain()
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 1177, in drain
await self.ensure_open()
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 920, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent
2021-09-27 22:34:54,930 - ERROR - fhempy.lib.fhem_pythonbinding: Connection closed error
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 944, in transfer_data
message = await self.read_message()
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 1013, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 1089, in read_data_frame
frame = await self.read_frame(max_size)
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 1148, in read_frame
extensions=self.extensions,
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/framing.py", line 70, in read
data = await reader(2)
File "/usr/lib/python3.7/asyncio/streams.py", line 679, in readexactly
await self._wait_for_data('readexactly')
File "/usr/lib/python3.7/asyncio/streams.py", line 473, in _wait_for_data
await self._waiter
concurrent.futures._base.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py", line 67, in pybinding
async for message in websocket:
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 481, in aiter
yield await self.recv()
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 552, in recv
await self.ensure_open()
File "/usr/local/lib/python3.7/dist-packages/websockets/legacy/protocol.py", line 920, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent
2021-09-27 22:34:54,935 - INFO - fhempy.lib.fhem_pythonbinding: Restart binding
2021-09-27 22:34:54,937 - INFO - websockets.server: connection closed
2021-09-27 22:35:00,059 - INFO - fhempy.lib.fhem_pythonbinding: Starting fhempy...
2021-09-27 22:35:00,129 - INFO - fhempy.lib.fhem_pythonbinding: Waiting for FHEM connection
2021-09-27 22:35:00,419 - WARNING - asyncio: Executing <Task pending coro=<async_main() running at /opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py:462> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0xb5b2b210>()] created at /usr/lib/python3.7/asyncio/tasks.py:615> cb=[_run_until_complete_cb() at /usr/lib/python3.7/asyncio/base_events.py:158] created at /usr/lib/python3.7/asyncio/base_events.py:563> took 0.360 seconds
2021-09-27 22:35:00,429 - INFO - websockets.server: server listening on 0.0.0.0:15733
2021-09-27 22:35:06,337 - INFO - websockets.server: connection open
2021-09-27 22:35:06,347 - INFO - fhempy.lib.fhem_pythonbinding: Incoming FHEM connection: 127.0.0.1
2021-09-27 22:35:06,429 - WARNING - asyncio: Executing <Handle <TaskWakeupMethWrapper object at 0xb5b2b3b0>() created at /usr/lib/python3.7/asyncio/streams.py:408> took 0.100 seconds
2021-09-27 22:35:15,457 - ERROR - tuya_cloud_connector: Tuya login error response: {'code': 1106, 'msg': 'permission deny', 'success': False, 't': 1632774915427}`

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

2021-09-27 22:35:15,457 - ERROR - tuya_cloud_connector: Tuya login error response: {'code': 1106, 'msg': 'permission deny', 'success': False, 't': 1632774915427}`

When did you create the tuya iot platform project? It needs to be created later than May 2021. If you just created it a few days ago you need to check clientid/secret, username/password again.

@Heiner1967
Copy link
Author

As username I take "Spitzname" from the Tuya App, thats the only name I have, if i take my Email, it's colored inside definition editor and does not work either

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

Could it be that you registered with Google instead of registering an account?

@Heiner1967
Copy link
Author

IOT platform project is now about 1 week old
I registered based on a gmail Mailadress in IOT Platform as well as in the Tuya App

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

You need to register an account and use the email address. You can find the username here (in my case the email address domi****.com - of course you need to use the full one)

image

@Heiner1967
Copy link
Author

clientID/secret is thhis in the overview, correct?

Access ID/Client ID:
Access Secret/Client Secret

checked

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

clientID/secret is thhis in the overview, correct?

Access ID/Client ID:
Access Secret/Client Secret

checked

yes

@Heiner1967
Copy link
Author

Heiner1967 commented Sep 27, 2021

if I use this Mail, in fhem definition the portion @gmail is marked in red, as well the last character of my Password which is this:& is marked in orange.

as result no new logentry !!

Do I need to do the registration with another Mailprovider?

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

no, it's actually not fhem which is marking it red, it might be just your browser which is doing a spellcheck.

@fhempy
Copy link
Owner

fhempy commented Sep 27, 2021

is the status "ready" now?

@Heiner1967
Copy link
Author

Heiner1967 commented Sep 28, 2021

Hi,

sorry neede to leave yesterdy night. No it is not.
Still failed to connect. With verbose 5 the fhem log says
2021.09.28 20:07:51 3: PythonModule v1.0.0 (tuya_cloud) 2021.09.28 20:07:51 4: PythonModule: fhempy not yet connected! Define will continue after connect...

Access ID and AccessSecret per copy paste added in.
neither Email as per TuyaApp nor "Spitzname" as per Tuya app does work , password (of Tuya App) checked once more
rest of the define is "tuyaSmart Europe" - should be correct as well, the Device is visible in IOT Platform as Central Europe, not Western Europe.

local_pybinding is status opened
Pytonbinding_15733 is active

the tuya modul things i deleted as suggested

no clue if important but Tuya app is open and the Tuya lightbulp is online

@Heiner1967
Copy link
Author

Heiner1967 commented Sep 28, 2021

I get crazy, I defined a second connector, same parameter all put in by copy paste and it works.
I thought i am stupid and copied paste both definitions below each other and all characters match. MEans a updated definition is not resulting in the same as a new definition !!!!

ok, so nice that this seems to be done, but how to get now the new device. IT should be autoatic created but there is nothing.
fhemlog says now
2021.09.28 20:27:55 3: PythonModule v1.0.0 (tuya_cloud)
2021.09.28 20:27:57 1: PERL WARNING: Use of uninitialized value in string eq at (eval 2482441) line 1.
2021.09.28 20:27:57 3: Please define Elitecho-GU10_5.5W_RGBCCT_W_150028062cf432xxxxxa first

Thats my lighbulp, but how to define it?

@fhempy
Copy link
Owner

fhempy commented Sep 28, 2021

it is defined automatically. Try to restart fhempy (Pythonbinding_15733) as it will load all devices from the cloud again.

@Heiner1967
Copy link
Author

Heiner1967 commented Sep 28, 2021

ok, i restarted, the connector goes into Connecting and after a while to PytonBinding timeout.
no device created.

fhempylog says
2021-09-28 20:44:48,430 - ERROR - tuya iot: Unexpected disconnection.1
[2021-09-28 20:44:49,572] [tuya-openmq] Unexpected disconnection.1
2021-09-28 20:44:49,572 - ERROR - tuya iot: Unexpected disconnection.1
2021-09-28 20:44:53,812 - INFO - fhempy.lib.fhem_pythonbinding: Starting fhempy...
2021-09-28 20:44:53,978 - INFO - fhempy.lib.fhem_pythonbinding: Waiting for FHEM connection
2021-09-28 20:44:54,344 - WARNING - asyncio: Executing <Task pending coro=<async_main() running at /opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py:462> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0xb5b4c1b0>()] created at /usr/lib/python3.7/asyncio/tasks.py:615> cb=[_run_until_complete_cb() at /usr/lib/python3.7/asyncio/base_events.py:158] created at /usr/lib/python3.7/asyncio/base_events.py:563> took 0.531 seconds
2021-09-28 20:44:54,360 - INFO - websockets.server: server listening on 0.0.0.0:15733
2021-09-28 20:45:00,620 - INFO - websockets.server: connection open
2021-09-28 20:45:00,631 - INFO - fhempy.lib.fhem_pythonbinding: Incoming FHEM connection: 127.0.0.1

and fhemlog says
2021.09.28 20:44:50 1: ws:127.0.0.1:15733 disconnected, waiting to reappear (local_pybinding)
2021.09.28 20:44:50 3: Pythonbinding_15733: read: end of file reached while sysread
2021.09.28 20:44:50 3: Pythonbinding_15733: stopped
2021.09.28 20:44:50 3: Pythonbinding_15733: starting
2021.09.28 20:44:50 3: Pythonbinding_15733: using logfile: ./log/fhempy-2021-09-28.log
2021.09.28 20:44:50 1: BindingsIo: ERROR local_pybinding - error while connecting: 127.0.0.1: Verbindungsaufbau abgelehnt (111)
2021.09.28 20:45:00 1: ws:127.0.0.1:15733 reappeared (local_pybinding)
2021.09.28 20:45:19 1: BindingsIo: ERROR: Timeout while waiting for function to finish (id: 36587417)
2021.09.28 20:45:19 1: PERL WARNING: Use of uninitialized value in string eq at (eval 2486521) line 1.
2021.09.28 20:45:20 3: Please define Elitecho-GU10_5.5W_RGBCCT_W_150028062cf432xxxxxa first

@fhempy
Copy link
Owner

fhempy commented Sep 28, 2021

Have you updated to the latest version? Timeout should have been fixed since about 1 or 2 weeks. Please do an update command in FHEM and restart FHEM afterwards.

@Heiner1967
Copy link
Author

Heiner1967 commented Sep 28, 2021

ok updated and restarted, no new device, restart pybinding again, no new device
fhempylog says
2021-09-28 21:23:32,099 - INFO - fhempy.lib.fhem_pythonbinding: Starting fhempy...
2021-09-28 21:23:32,143 - INFO - fhempy.lib.fhem_pythonbinding: Waiting for FHEM connection
2021-09-28 21:23:32,298 - WARNING - asyncio: Executing <Task pending coro=<async_main() running at /opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py:462> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0xb5bba0d0>()] created at /usr/lib/python3.7/asyncio/tasks.py:615> cb=[_run_until_complete_cb() at /usr/lib/python3.7/asyncio/base_events.py:158] created at /usr/lib/python3.7/asyncio/base_events.py:563> took 0.199 seconds
2021-09-28 21:23:32,305 - INFO - websockets.server: server listening on 0.0.0.0:15733
2021-09-28 21:23:40,639 - INFO - websockets.server: connection open
2021-09-28 21:23:40,656 - INFO - fhempy.lib.fhem_pythonbinding: Incoming FHEM connection: 127.0.0.1
fhemlog
2021.09.28 21:23:29 3: Pythonbinding_15733: read: end of file reached while sysread
2021.09.28 21:23:29 3: Pythonbinding_15733: stopped
2021.09.28 21:23:29 3: Pythonbinding_15733: starting
2021.09.28 21:23:29 3: Pythonbinding_15733: using logfile: ./log/fhempy-2021-09-28.log
2021.09.28 21:23:29 1: ws:127.0.0.1:15733 disconnected, waiting to reappear (local_pybinding)
2021.09.28 21:23:30 1: BindingsIo: ERROR local_pybinding - error while connecting: 127.0.0.1: Verbindungsaufbau abgelehnt (111)
2021.09.28 21:23:40 1: ws:127.0.0.1:15733 reappeared (local_pybinding)
2021.09.28 21:23:46 1: PERL WARNING: Use of uninitialized value in string eq at (eval 6526) line 1.
2021.09.28 21:23:46 3: Please define Elitecho-GU10_5.5W_RGBCCT_W_150028062cf43xxxxxa first

@fhempy
Copy link
Owner

fhempy commented Sep 28, 2021

Please post the fhempy log with tuya_cloud setup device verbose=5. Do a restart after that to have a clean log.

@fhempy
Copy link
Owner

fhempy commented Sep 28, 2021

Can you please try
define Elitecho-GU10_5.5W_RGBCCT_W_150028062cf43xxxxxan dummy

I think the bug might be the length of the name.

@fhempy
Copy link
Owner

fhempy commented Sep 28, 2021

Ok "-" is the character which isn't supported in FHEM. I'll update fhempy to replace that one.

@fhempy
Copy link
Owner

fhempy commented Sep 28, 2021

Please do

set local_pybinding update

and wait till update is finished. It's finished when local_pybinding is opened again. This might take up to some minutes.

After that your device should be available.

@Heiner1967
Copy link
Author

Hurra, it works 🥇
Many Thanks for creating fhempy and many more thanks for getting this thing for me to work.

Thats super cool now

@fhempy
Copy link
Owner

fhempy commented Sep 28, 2021

Perfect 👍

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