ggeorgovassilis / linuxscripts Goto Github PK
View Code? Open in Web Editor NEWScript collection for linux
License: Other
Script collection for linux
License: Other
Hi
Here is my small contribution to the script: a way to shedule to turn off the plug (hardcoded to 30 minutes). If called another time, the last call cancel any previous schedule and reset the schedule to 30 min.
I trigger that command when a printer finish its job, in order to turn off that printer after a while, if no other print job is launched (in which case, the timeout is reset to 30 min on each print job).
cmd_schedule_switch_off(){
# Cancel any scheduled turn-off
# Browse all AT tasks and, for those containing the script name ($0), ask AT to stop them
for j in $(atq | cut -f 1);
do
if at -c $j | grep -q $0; then
echo Stop scheduled turn-off task $j
at -r $j
fi
done
# Schedule in 30 minutes to turn off the plug
echo "$0 $ip $port off" | at now+30minute
}
I'm running on an HS100, HW version 2.0, FW version 1.5.6 (as reported by Kasa App).
When running, I get an error and invalid result from "check" (my device is actually ON in the test below):
$ ./hs100.sh 192.168.1.25 9999 check
args are 192.168.1.25 9999 check
Connection to 192.168.1.25 9999 port [tcp/*] succeeded!
od: cannot skip past end of combined input
OFF
The reason is that in send_to_plug(), netcat returns nothing even though the payload is send successfully, and od
complains about no input. I'm suspecting this broke in later firmware.
Also note: the on/off commands work perfectly. They don't need any output to work, of course.
Hi,
I installed openhab on raspberry using hasbian and when i launch the script using this command:
sudo ./hs100.sh 192.168.0.200 9999 on
i am getting this message:
"The nc programme for sending data over the network isn't in the path, communication with the plug will fail
The same script with same command launched on my mac works without any issue..
What does the message mean?
Thank you
Hi! This is a wonderful script, but I've run into two things. Maybe I'm doing something wrong, but I don't think so. When I run:
sudo hs100.sh discover
the script asks for the IP address. In perusing your code, I found that it doesn't seem to look for anything other than the IP and port. Here's my dumb little hack that made it work for me:
check_arguments() {
if [ $BASH_ARGV[1] != "discover" ] && [ $BASH_ARGV[1] != "list" ]; then
check_arg() {
name="$1"
value="$2"
if [ -z "$value" ]; then
echo "missing argument $name"
usage
fi
}
check_arg "ip" $plugs
check_arg "port" $port
check_arg "cmd_dis" $cmd
fi
}
Also, when I do discovery, it picks up an IP camera on the network and throws it in the list, which I think is because the IP camera has port 9999 open. Just FYI.
One last thing: Would you consider implementing the {"system":{"reboot":{"delay":1}}} function? I'm using the code to reset a funky POE switch that the computer happens to be connected to, thus it's a bit tough to turn the thing back on through code!
Thank you so much!
hello,
i can confirm that your code is also working for the HS110 model.
i would like to flash a custom image with a simple REST interface to control the smart plug.
kind regards, werty
The repository needs a license. We need a public domain contributor & user license.
Hi George,
I'm new to HA and all the scripting. I was wondering what values you changed in the script for use with your own IP etc? I can't figure out from the script which values to change myself.
Also - do you happen to share the switch code you used in HA? Thank you so much!
Hello.
I'm trying to use your script to do 3 basic things:
It's an HS100 with Hardware version 1.0 and Firmware version 1.1.0 Build 160503 Rel.145047 (also tried in an HS110 with Hardware version 1.0 and Firmware version 1.0.8 Build 151101 Rel.24452 and result is the same).
Is there anything I can provide you for you to check, or am I doing something wrong?
Thanks in advance and kind regards.
I've been trying to figure out how to properly do this, but how would you grab all of nord's servers that use socks proxy, and roundrobin between all of them? Also, including the authentication in the HAproxy configuration? Is it like reqadd Proxy-Authentication:?
Confirmed that it works on HS200 (TP-Link Smart Switch) as well
I found that running the status payload was returning binary characters, adjusting cmd_print_plug_relay_state() to the following strips it out (added tr -cd '\11\12\15\40-\176'):
output=send_to_plug $ip $port "$payload_query" | decode | tr -cd '\11\12\15\40-\176' | egrep -o 'relay_state":[0,1]' | egrep -o '[0,1]'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.