I am attempting to build a Plugin to communicate with my Kasa HS110 Energy plugs. I originally developed a Java program I can use and it works fine. I have been converting it into JS for HR. For the HS110 the command string must be encoded and sent with a binary file. My Plugin function to encode the command string works, I can send strings to it and compare the returned byte[] Array with the byte[] Array generated from my Java version and they are identical.
In my Java version I open a socket and use I/O streams without any issues but when I send the same data with the TCPClient() I get the error “No public methods with the specified arguments were found.”
This is a snippet of how it should work:
// Send command string to function to encode into a byte[]Array, then send
Packed=Pack("{“system”:{“set_relay_state”:{“state”:0}}}");
tcp.send(Packed);
After searching Plugins written by other people I saw a couple of ways commands were sent so I tried building the data manually and sending it. Either I would get the same error or sometimes no error but the command never worked with the plug. Here are some of the ways I tried.
var sendcommand=[0,0,0,42,-48,-14,-127,-8,-117,-1,-102,-9,-43,-17,-108,-74,-59,-96,-44,-117,-7,-100,-16,-111,-24,-73,-60,-80,-47,-91,-64,-30,-40,-93,-127,-14,-122,-25,-109,-10,-44,-18,-34,-93,-34,-93];
tcp.send(sendcommand);
tcp.send(“0,0,0,42,-48,-14,-127,-8,-117,-1,-102,-9,-43,-17,-108,-74,-59,-96,-44,-117,-7,-100,-16,-111,-24,-73,-60,-80,-47,-91,-64,-30,-40,-93,-127,-14,-122,-25,-109,-10,-44,-18,-34,-93,-34,-93”);
tcp.send(“0x00,0x00,0x00,0x2A,0xD0,0xF2,0x81,0xF8,0x8B,0xFF,0x9A,0xF7,0xD5,0xEF,0x94,0xB6,0xC5,0xA0,0xD4,0x8B,0xF9,0x9C,0xF0,0x91,0xE8,0xB7,0xC4,0xB0,0xD1,0xC0,0xE2,0xD8,0xA3,0x81,0xF2,0x86,0xE7,0x93,0xF6,0xD4,0xEE,0xDE,0xA3,0xDE,0xA3”);
tcp.send("\x00\x00\x00\x2A\xD0\xF2\x81\xF8\x8B\xFF\x9A\xF7\xD5\xEF\x94\xB6\xC5\xA0\xD4\x8B\xF9\x9C\xF0\x91\xE8\xB7\xC4\xB0\xD1\xC0\xE2\xD8\xA3\x81\xF2\x86\xE7\x93\xF6\xD4\xEE\xDE\xA3\xDE\xA3");
tcp.send("\0x00\0x00\0x00\0x2A\0xD0\0xF2\0x81\0xF8\0x8B\0xFF\0x9A\0xF7\0xD5\0xEF\0x94\0xB6\0xC5\0xA0\0xD4\0x8B\0xF9\0x9C\0xF0\0x91\0xE8\0xB7\0xC4\0xB0\0xD1\0xC0\0xE2\0xD8\0xA3\0x81\0xF2\0x86\0xE7\0x93\0xF6\0xD4\0xEE\0xDE\0xA3\0xDE\0xA3");
I started my Plugin by copying the code from the TCP Client example on The Home Remote website into the Plugin I created in designer. Is this the right way to start? or did I have to import a TCP Client Plugin and add my code to it?
Wireshark confirms that the binary data is never sent but an ASCII string does go but will do nothing with the Kasa device.
What can I do?
Jerry