From 386aefb54321aef36be1b717c1d7b9580460117d Mon Sep 17 00:00:00 2001 From: JsBergbau <37013344+JsBergbau@users.noreply.github.com> Date: Wed, 22 Jan 2020 13:29:42 +0000 Subject: [PATCH 1/3] Tempbranch (#1) * Update README.md * Add files via upload --- README.md | 10 ++++++++++ settime.sh | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 settime.sh 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..8694e2b --- /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 From db627e0f514903e8436279a859facdd03661d854 Mon Sep 17 00:00:00 2001 From: JsBergbau <37013344+JsBergbau@users.noreply.github.com> Date: Mon, 4 May 2020 11:17:29 +0000 Subject: [PATCH 2/3] Add files via upload --- settime.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/settime.sh b/settime.sh index 8694e2b..96391ce 100644 --- a/settime.sh +++ b/settime.sh @@ -16,9 +16,9 @@ do jahr=$(date +"%Y") monat=$(date +"%m") tag=$(date +"%d") - stunde=$(date +"%H") - minute=$(date +"%M") - sekunde=$(date +"%S") + 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 From 7575f35cc822870cfce32418a8a2b38dd11a006f Mon Sep 17 00:00:00 2001 From: JsBergbau <37013344+JsBergbau@users.noreply.github.com> Date: Mon, 1 Jun 2020 15:21:30 +0000 Subject: [PATCH 3/3] Allows to set time by MAC of device --- settimeByMAC.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 settimeByMAC.sh 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