Closed Vaszago closed 3 years ago
That error message is from the regular tuya integration, not localtuya. Please check the log again. You might run into problems if you use both integrations at the same time.
Deleted the Tuya app. But still can't connect.
There debug Log
2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Started heartbeat loop 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Send payload: b'{}' 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Waiting for sequence number -100 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Sending command status (device type: type_0a) 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Send payload: b'{"gwId":"205284415002912a6705","devId":"205284415002912a6705"}' 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Waiting for sequence number 1 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Got heartbeat response 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Decrypted payload: {} 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b"\xe3\x03\x87\xd9\x86\xc0\xe7\x8e4*k(]k<\xd2\x88{\xb0\xc0'\x07\xba\xcd\xd7~\x8e\xc0z\xae&\x88", crc=1455407576) 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Dispatching sequence number 1 2020-11-18 19:04:11 ERROR (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Failed to get status: 'utf-8' codec can't decode byte 0xfa in position 0: invalid start byte Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 466, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 428, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 413, in exchange payload = self._decode_payload(msg.payload) File "/config/custom_components/localtuya/pytuya/init.py", line 500, in _decode_payload payload = self.cipher.decrypt(payload, False) File "/config/custom_components/localtuya/pytuya/init.py", line 163, in decrypt return self._unpad(decryptor.update(enc) + decryptor.finalize()).decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfa in position 0: invalid start byte 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Closing connection 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Connection lost: None 2020-11-18 19:04:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Closing connection 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Started heartbeat loop 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Send payload: b'{}' 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Waiting for sequence number -100 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Sending command status (device type: type_0a) 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Send payload: b'{"gwId":"205284415002912a6705","devId":"205284415002912a6705"}' 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Waiting for sequence number 1 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Got heartbeat response 2020-11-18 19:04:18 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Decrypted payload: {} 2020-11-18 19:04:21 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:21 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Send payload: b'{}' 2020-11-18 19:04:21 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Waiting for sequence number -100 2020-11-18 19:04:21 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:21 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Got heartbeat response 2020-11-18 19:04:21 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Decrypted payload: {} 2020-11-18 19:04:23 ERROR (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Failed to get status: Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 466, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 428, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 407, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 206, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.8/asyncio/tasks.py", line 498, in wait_for raise exceptions.TimeoutError() asyncio.exceptions.TimeoutError 2020-11-18 19:04:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Closing connection 2020-11-18 19:04:23 ERROR (MainThread) [custom_components.localtuya.config_flow] Unexpected exception Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 238, in async_step_basic_info self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 173, in validate_input detected_dps = await interface.detect_available_dps() File "/config/custom_components/localtuya/pytuya/init.py", line 466, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 428, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 407, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 206, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.8/asyncio/tasks.py", line 498, in wait_for raise exceptions.TimeoutError() asyncio.exceptions.TimeoutError 2020-11-18 19:04:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Connection lost: None 2020-11-18 19:04:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Closing connection 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Started heartbeat loop 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Send payload: b'{}' 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Waiting for sequence number -100 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Sending command status (device type: type_0a) 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Send payload: b'{"gwId":"205284415002912a6705","devId":"205284415002912a6705"}' 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Waiting for sequence number 1 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Got heartbeat response 2020-11-18 19:04:27 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Decrypted payload: {} 2020-11-18 19:04:29 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:29 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Send payload: b'{}' 2020-11-18 19:04:29 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Waiting for sequence number -100 2020-11-18 19:04:29 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:29 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Got heartbeat response 2020-11-18 19:04:29 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Decrypted payload: {} 2020-11-18 19:04:30 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:30 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Send payload: b'{}' 2020-11-18 19:04:30 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Waiting for sequence number -100 2020-11-18 19:04:30 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:30 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Got heartbeat response 2020-11-18 19:04:30 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Decrypted payload: {} 2020-11-18 19:04:32 ERROR (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Failed to get status: Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 466, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 428, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 407, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 206, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.8/asyncio/tasks.py", line 498, in wait_for raise exceptions.TimeoutError() asyncio.exceptions.TimeoutError 2020-11-18 19:04:32 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Closing connection 2020-11-18 19:04:32 ERROR (MainThread) [custom_components.localtuya.config_flow] Unexpected exception Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 238, in async_step_basic_info self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 173, in validate_input detected_dps = await interface.detect_available_dps() File "/config/custom_components/localtuya/pytuya/init.py", line 466, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 428, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 407, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 206, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.8/asyncio/tasks.py", line 498, in wait_for raise exceptions.TimeoutError() asyncio.exceptions.TimeoutError 2020-11-18 19:04:32 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Connection lost: None 2020-11-18 19:04:32 DEBUG (MainThread) [custom_components.localtuya.pytuya] [205284415002912a6705] Closing connection 2020-11-18 19:04:39 ERROR (MainThread) [frontend.js.latest.202010214] http://192.168.1.99:8123/api/panel_custom/uilogs:20:11471 Uncaught NotSupportedError: Failed to execute 'define' on 'CustomElementRegistry': the name "mwc-list-item" has already been used with this registry 2020-11-18 19:04:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Send payload: b'{}' 2020-11-18 19:04:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Waiting for sequence number -100 2020-11-18 19:04:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Got heartbeat response 2020-11-18 19:04:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Decrypted payload: {} 2020-11-18 19:04:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Send payload: b'{}' 2020-11-18 19:04:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Waiting for sequence number -100 2020-11-18 19:04:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Got heartbeat response 2020-11-18 19:04:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c4948c] Decrypted payload: {} 2020-11-18 19:04:50 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Sending command heartbeat (device type: type_0a) 2020-11-18 19:04:50 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Send payload: b'{}' 2020-11-18 19:04:50 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Waiting for sequence number -100 2020-11-18 19:04:50 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:04:50 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Got heartbeat response 2020-11-18 19:04:50 DEBUG (MainThread) [custom_components.localtuya.pytuya] [04200408b4e62d191fc7] Decrypted payload: {} 2020-11-18 19:05:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Sending command heartbeat (device type: type_0a) 2020-11-18 19:05:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Send payload: b'{}' 2020-11-18 19:05:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Waiting for sequence number -100 2020-11-18 19:05:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2020-11-18 19:05:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Got heartbeat response 2020-11-18 19:05:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [60424556600194c470e9] Decrypted payload: {}
I was able to connect all devices which require protocol 3.1 with Tuyalocal. The SP112 apparently need protocol 3.3 and so the connection does not seem to work. Waiting for a new version of Tuyalocal.
I have a Gosund SP112. This is my configuration:
---
- host: !env_var SMART_PLUG_USB_IP
device_id: !secret smart_plug_usb.id
local_key: !secret smart_plug_usb.key
friendly_name: Smart plug USB
protocol_version: "3.3"
entities:
- platform: switch
friendly_name: Left monitor
id: 1
current: 20
current_consumption: 19
voltage: 18
- platform: switch
friendly_name: USB
id: 7
- platform: sensor
friendly_name: Left monitor energy consumption
id: 19
scaling: 0.1
device_class: power
unit_of_measurement: "W"
Does it not work for you?
In which file is this entry. Could not find. Can I take it over with my ID to connect SP112
There are two ways to configure Localtuya. The first one is using Home Assistant UI, which is probably the option you have chosen. The content I pasted is the second option which is configuring it with the configuration YAML files.
It does not really matter which option you are using - the values for the configuration are the same. Basically, you see in my config file how to configure your Gosund SP 112:
local_key
, device_id
and host
- you already have them, since you connected to your device correctly1
is the ID of the main switch (turning the whole switch on/off)20
is the current of the main switch (A)19
is the energy consumption of the main switch (W)18
is the voltage of the main switch (V)7
is the ID of the USB switch (turning on/off both USBs)Have you installed the Tuya APP and the localtuya simultaneously.
I get this error message that the key is not correct.
It is possible that the key is displayed incorrectly on iot.tuya.com. Can I check the key where?
If I enter the device via the Yaml file, the device is found, but the functions do not work.
I don't know what to do next
Are you positive you are providing the proper local_key
and device_id
? How did you obtain them?
I have followed the tutorial https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md#linking-a-tuya-device-with-smart-link and got the values by resetting the plug (it was blinking with blue light) and using the tuya-cli link
tool - it printed the values when it finished (it took about 1 minute).
These are my keys and ID. I was able to connect all of them except the two SP112. I will now try the 1 method to read the keys and see if they are the same with my list.
After querying via the CLI, I received completely different keys, and now the query works.
Thanks for your help
Sure thing, I am happy I could help :) Maybe the docs should be more clear about receiving the proper keys to your device, not the Tuya API itself.
I was able to connect to three other sockets with Tuyalocal without any problems. Only with the two Gosund Sp112 does the connection fail. I have the keys from Tuya. Here is the error message.
2020-11-18 17:17:36 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.xxxxxxx fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update raise exc File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/tuya/init.py", line 255, in update self._tuya.update() File "/usr/local/lib/python3.8/site-packages/tuyaha/devices/switch.py", line 16, in update return self._update(use_discovery=True) File "/usr/local/lib/python3.8/site-packages/tuyaha/devices/base.py", line 84, in _update devices = self.api.discovery() File "/usr/local/lib/python3.8/site-packages/tuyaha/tuyaapi.py", line 188, in discovery response = self._request("Discovery", "discovery") File "/usr/local/lib/python3.8/site-packages/tuyaha/tuyaapi.py", line 267, in _request self._raise_frequently_invoke( File "/usr/local/lib/python3.8/site-packages/tuyaha/tuyaapi.py", line 292, in _raise_frequently_invoke raise TuyaFrequentlyInvokeException(message) tuyaha.tuyaapi.TuyaFrequentlyInvokeException: Method [Discovery] fails 1 time(s) using poll interval 60.0 - error: you can discovery once in 600 seconds