jasonacox / tuyapower

Python module to read status and energy monitoring data from Tuya based WiFi smart devices. This includes state (on/off), current (mA), voltage (V), and power (wattage).
MIT License
140 stars 22 forks source link

Timeout polling device #6

Closed ferni7 closed 4 years ago

ferni7 commented 4 years ago

So I have 6 Kogan Plugs identical including firmware version(1.1.2 according to tuya app). https://www.kogan.com/au/buy/kogan-smarterhome-smart-plug-energy-meter-5v-24a-usb-ports-4-pack/

I can poll 5 of them for power using your script, but one just refuses to and I can't figure out why, Any ideas on how to troubleshoot?

nmap port scan shows 6667 and 6668 as closed (same as another plug that is working):

PORT STATE SERVICE 6667/udp closed ircu 6668/udp closed ircu

~/tuyapower$ python3 test.py xxxx 192.168.1.zz yyy 3.3 ERROR: Timeout polling device

TuyaPower (Tuya Power Stats) [0.0.20]

Device xxx at 192.168.1.zz key yyy protocol 3.3: Switch On: False Power (W): -99.000000 Current (mA): -99.000000 Voltage (V): -99.000000 Projected usage (kWh): Day: -2.376000 Week: -16.632000 Month: -72.072000

{ "datetime": "2020-07-26T13:45:18Z", "switch": "False", "power": "-99", "current": "-99", "voltage": "-99" }

ferni7 commented 4 years ago

Ok ignore this. I changed the IP of the device to something different and now it's responding, so guessing some kind of weird arp cache issue?

jasonacox commented 4 years ago

Hi @ferni7 I would be curious if you see all of the devices if you do a scan:

python3 -m tuyapower

In that mode, tuyapower is set to listen to udp announce events on 6667 and 6668. I would be interested to see if it is picking up the Kogan broadcast or if they are doing some silent running mode.

ferni7 commented 4 years ago

I did run that before i changed IP and no it didn't pick it up...

I just ran it again now, and it picked up 7 out of about a dozen... ran it a second time and it found 7 again (although 1 was different)

jasonacox commented 4 years ago

Thank you, that's helpful! I worried that I wasn't giving enough time to pick up all the broadcast events. Can you try with the latest v.20 version?

python3 -m pip install --upgrade tuyapower

Thanks again for your help.

ferni7 commented 4 years ago

No problems 👍

Upgraded and ran it a few times in a row, I have 10 of those plugs.... plus some other Tuya devices (Outdoor plug, Kettle, Lightbulbs which don't report in)....

I'm still having issues with that one plug in the OP. I changed the IP again and power cycled it and it reported for a while but dropped off again... that plug is the only one causing me issues... I can ping it, i can see it in tuya and turn it on/off, and I can turn it on/off with homekit via homebridge and tuya-lan plugin but it just won't report energy properly

TuyaPower (Tuya compatible smart plug scanner) [0.0.20] .... Scan Complete! Found 9 devices.

Scan Complete! Found 8 devices.

Scan Complete! Found 7 devices.

Scan Complete! Found 7 devices.

But sometimes the devices are different...