Z-Wave-Me / home-automation

Z-Way Home Automation engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automation module for TPLink HS100/110 need an update for encrypt function

mib1185 opened this issue · comments

Hi,

on function encrypt you init the result var with 4 zeros:
var result = "\0\0\0\0";
But there was an firmware update from TPLink which needs to have the length of command to be encrypted on first 4 bytes.
I´ve modified the encrypt funtion on my local installation and tested with newly bought HS110 (testes with firmware 1.5.2 and 1.5.4)

this.encrypt = function(data) {
        var key = 171;
        // var result = "\0\0\0\0";
        var result = "";
        for (var i = 3 ; i >= 0 ; i--) {
                result += String.fromCharCode( (data.length>>(8*i))&255 );
        }
        for (var i = 0, len = data.length; i < len; i++) {
                key = key^data.charCodeAt(i);
                result += String.fromCharCode(key);
        }
        return result
}

After some googling i`ve found the following commit on softScheck/tplink-smartplug repo:
softScheck/tplink-smartplug@7fabe45

Without modification, the wifi plug is not switched, because the plug does simple ignore the request.

regards,
Michael

Hi,

Unfortunately we only own a HS100 plug and there is no update offered. With the currently installed version (1.2.5) there are no problems with the app. Do you know which version introduced the new encryption? If so, we can adapt the app to check the version of the plug first and use the correct encryption based on the version.

Hi,

i´m not realy sure, when this change happend on firmware.
Nethertheless, without this modification, you`ll not be able to check firmware's version, because every request is ignored by plug (additional tested with hs110 on firmware 1.4.3).
Please could you test, if these modification does also work with your hs100 on 1.2.5?
If so, i would suggest to add this modification independend on plug's firmware version.

regards,
Michael

Hi,

I tried the new version of the encryption function. For our plug it's working too. It will be added to the next release. See https://github.com/Z-Wave-Me/home-automation/commit/54762807df1ce15909a0562217455afe2675bc94
Thank you for your help