kj831ca / KasaSmartPlug

Arduino Library for TP Link KASA Smart Plug
MIT License
12 stars 5 forks source link

JSON No memory error #2

Open ispybadguys opened 1 year ago

ispybadguys commented 1 year ago

I tried running this on an ESP32. I have two HS300 power strips. I am getting these results:

Enter select function... Select value = 1 Waiting incomming package... received 1023 bytes from 192.168.1.27: Parsing info... deserializeJson() failed: NoMemory Enter select function... Select value = 1 Waiting incomming package... received 968 bytes from 192.168.1.25: Parsing info... deserializeJson() failed: NoMemory Enter select function... Select value = 0 S Timeout Send Query Message Query Message sent

Found device = 0

Thanks Kurt

kj831ca commented 1 year ago

My device only return around 500 - 800 bytes of data. You can try to increase the "StaticJsonDocument<512> doc;" located on line 80 of KasaSmartPlug.cpp to "StaticJsonDocument<1024> doc;" and in file KasaSmartPlug.hpp line 44 as well.

You may have to increase the buffer size on line 410 : char buffer[1024] to char buffer[2000]; .

Regards Kris

ispybadguys commented 1 year ago

Thanks. I changed the char buffer to [2048] and StaticJsonDocument<1536> doc; And all is working. I do have a KP115 but it isn't listing it as found. Did the code for this in the other issue get integrated?

Thanks Kurt

kj831ca commented 1 year ago

You can try to change KasaSmartPlug.cpp line 216 "if (IsStartWith("HS",model)) " to "if(IsStartWith("HS",model) || IsStartWith("KP",model))" . The software should be able to recognize the KP model now. I don't have the KP model hardware so I don't know if it will work correctly or not.

Jack0r commented 1 year ago

With the 3 changes mentioned, I was able to detect my KP115 devices and can control them just fine. Getting the state and turning them on and off is working.

Thank you for your work on this library!