/TPLink-hs100-PHP-REST-API

PHP rest api for tplink hs1'' smart plugs

Primary LanguagePHP

TPLink hs100 PHP api

PHP rest api for tplink hs100 smart plugs

NOTE You need have an account on "Kasa" app, and register your plugs on it

Usage

define("TPLINK_USER", "XXXXX"); //Login email
define("TPLINK_PASS", "XXXXX"); //Login password

require 'tplink.class.php';

$tplink = new TpLink();
/* Get an array of all smart plugs */
$plugs = $tplink->getDeviceList();

/* Set on first plug */
$tplink->plugSwitch(true, array(    // bool, default false
	"deviceId" => $plugs[0]['deviceId'], // deviceId, default none
	"useUrl" => $plugs[0]['useUrl']      // optional specify appServerUrl (Previously provided)
));	

Commands

myTerminal (null)

Return your uid

returnToken (null)

Login and return your tplink token

getDeviceList (null)

Get an complete list of your plugs, can take some time

/* Example response */
Array
(
    [0] => Array
        (
            [deviceId] => XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
            [name] => Riego
            [deviceName] => Wi-Fi Smart Plug HS100(EU)
            [mac] => XXXXXXXXXXX
            [useUrl] => https://use1-wap.tplinkcloud.com
            [working] => 1
            [relay_status] => off
            [geo] => Array
                (
                    [lat] => -XX.XXXXX
                    [lon] => -XX.XXXXX
                )

            [Ids] => Array
                (
                    [fwId] => XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                    [hwId] => XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                    [oemId] => XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                )

        )
        ...

plugSwitch (bool, Array)

Send command to plug, true / false, and deviceId in array

License

MIT License

2017