jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
868 stars 157 forks source link

TCPPORT as argument #404

Closed SteanlyCZ closed 10 months ago

SteanlyCZ commented 10 months ago

Hello,

I need to access remotely using WAN, this means that each device from outside must have a different port...

Would it be possible to add the TCPPORT variable as an argument?

For example: d = tinytuya.OutletDevice( dev_id='DEVICE_ID_HERE', address='IP_ADDRESS_HERE', tcp_port='TCP_PORT_HERE', local_key='LOCAL_KEY_HERE', version=3.3)

uzlonewolf commented 10 months ago

You like to live dangerously I see :sunglasses:

Shouldn't be too hard. Instead of making it another option, tacking it onto the address as a port specifier might be better, i.e. address='1.2.3.4:5678'

uzlonewolf commented 10 months ago

In the meantime, it looks like the current code allows it to be changed with:

d = tinytuya.OutletDevice( dev_id='DEVICE_ID_HERE', address='IP_ADDRESS_HERE', local_key='LOCAL_KEY_HERE',  version=3.3)
d.port = TCP_PORT_HERE
SteanlyCZ commented 10 months ago

In the meantime, it looks like the current code allows it to be changed with:

d = tinytuya.OutletDevice( dev_id='DEVICE_ID_HERE', address='IP_ADDRESS_HERE', local_key='LOCAL_KEY_HERE',  version=3.3)
d.port = TCP_PORT_HERE

this works, thank you!!!