diff --git a/README.md b/README.md index a3ae145..c9de62b 100644 --- a/README.md +++ b/README.md @@ -87,3 +87,13 @@ Reading out the WAN link status on an Archer C9 in default configuration shows t Reply Data: Version 02 Type 03 Status 00 Length 00000018 ID 0001 Subtype 0e Decrypted: wan_ph_link 1 0 ``` + +## settime.sh + +Especially when you disconnect your Smartplug from the Cloud, the time is not set. Without time set you can't use several functions in the Kasa App, like countdown, shedules or get proper total energy consumption. + +With this script you can set the time. + +It has to be placed in the same folder as the tplink_smartplug.py + +Usage: `./settime.sh ` and so on diff --git a/settime.sh b/settime.sh new file mode 100644 index 0000000..96391ce --- /dev/null +++ b/settime.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ $# -eq 0 ] + then + echo "Usage: settime.sh IP1 IP2 ..." + exit 1 +fi + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# Set Timezone +# {"time":{"set_timezone":{"year":2016,"month":1,"mday":1,"hour":10,"min":10,"sec":10,"index":42}}} + +for i in "$@" +do + jahr=$(date +"%Y") + monat=$(date +"%m") + tag=$(date +"%d") + stunde=$(date +"%-H") + minute=$(date +"%-M") + sekunde=$(date +"%-S") + echo $DIR/tplink_smartplug.py -t $i -j "{\"time\":{\"set_timezone\":{\"year\":$jahr,\"month\":$monat,\"mday\":$tag,\"hour\":$stunde,\"min\":$minute,\"sec\":$sekunde,\"index\":42}}}" + $DIR/tplink_smartplug.py -t $i -j "{\"time\":{\"set_timezone\":{\"year\":$jahr,\"month\":$monat,\"mday\":$tag,\"hour\":$stunde,\"min\":$minute,\"sec\":$sekunde,\"index\":42}}}" +done \ No newline at end of file diff --git a/settimeByMAC.sh b/settimeByMAC.sh new file mode 100644 index 0000000..defa24b --- /dev/null +++ b/settimeByMAC.sh @@ -0,0 +1,12 @@ +#!/bin/bash +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +if [ $# -ne 1 ] + then + echo "Usage: settime.sh " + echo "Important: Contact must have been made, so that MAC address is in arp table" + exit 1 +fi + +IP=$(arp -n | grep -i $1 | grep -oP '^[^\s]+') + +$DIR/settime.sh $IP \ No newline at end of file