rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.84k stars 545 forks source link

wrong folder after last update (3.0.2) #99

Closed carlosCastro99 closed 3 years ago

carlosCastro99 commented 3 years ago

it seems that the last update has a bug. it's writing files in directory /config/custom_components/localtuya/custom_components/localtuya. Had to move them manually.

rospogrigio commented 3 years ago

Yeah sorry guys, I made some mess, please downgrade back to 3.0.1 and wait for localtuya to be added into HACS natively. Thank you

sabellwind commented 3 years ago

Hi guys, firstly, thanks for getting this going. It's looking very promising!

Not sure if this is related, but I downgraded, and now my device is not showing up anymore. It is not discovering automatically, and when added manually and via yaml, the following error is thrown:

Connect to 192.168.1.134 failed
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 151, in _make_connection
    status = await self._interface.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 429, in status
    if "dps" in status:
TypeError: argument of type 'NoneType' is not iterable
localtuya:
  - host: 192.168.1.134
    device_id: xxx
    local_key: xxx
    friendly_name: Bedroom Humidifier
    protocol_version: "3.3"
    entities:        
      - platform: switch
        friendly_name: Bedroom Humidifier Switch
        id: 1 
      - platform: light
        friendly_name: Bedroom Humidifier Light
        id: 11

edit: saw this come up too

Connect to 192.168.1.134 failed
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 141, in _make_connection
    self._interface = await pytuya.connect(
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 593, in connect
    _, protocol = await loop.create_connection(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 494, in sock_connect
    return await fut
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 526, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionResetError: [Errno 104] Connect call failed ('192.168.1.134', 6668)
postlund commented 3 years ago

@sabellwind I have seen that issue as well, I think the device decides to close the connection. I will commit a workaround for it.

sabellwind commented 3 years ago

Hi @postlund I managed to trace the issue in this instance to TuyaGateway running at the same time. I was experimenting with it but gave up after I came across this more simply put together integration. It was configured with the device ID, virtual key and IP, but not much more than that.

Seems as if adding the device won't work if it's actively being engaged by another platform, (tuya, TuyaGateway etc.)

Thanks for following up

postlund commented 3 years ago

@sabellwind that sounds very reasonable. Some (most) devices only accept one connection at the time.

postlund commented 3 years ago

Should be fixed now.