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

OSError: [Errno 98] Address already in use #407

Open ausghostdog opened 9 months ago

ausghostdog commented 9 months ago

Hi, Setting up tinytuya and am getting image image attempting to run

python3 -m tinytuya wizard image gives the same

however, entering a device ID did give image

Which gave me the local key

I also tried running as root, image with the same error, I did however get the details I wanted

jasonacox commented 9 months ago

Something is already listening to the UDP port (it looks like a python3 service with a PID 2526 in the netstat screenshot). Did you kill that process and try again? Both scan and wizard will try to listen to get a Device ID broadcast from a Tuya device on your network. Wizard will bypass that if you provide the Device ID.

ausghostdog commented 9 months ago

Thanks, yeah home asssistant is running on that, but the Wizard got me what I wanted.

jasonacox commented 9 months ago

Thanks @ausghostdog - We could add error checking and provide the user more useful information (e.g. shut down the other service on your computer with port x open).

ausghostdog commented 9 months ago

Is there an option to run tiny on a different port? Or to pass a custom port as the run?

jasonacox commented 9 months ago

The Tuya devices send out a multicast broadcast on UDP ports 6666 and 6667. That is hardcoded into the firmware of the Tuya devices. To discover the devices, you need to open a listener on your computer for those broadcasts. This is what TinyTuya does to discover devices on your network. Only one application can listen at any given time. If HA is listening, TinyTuya won't be able to listen.