Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hs100: new schedule_off command (code included) #16

Open
OhSoGood opened this issue Jun 27, 2021 · 0 comments
Open

hs100: new schedule_off command (code included) #16

OhSoGood opened this issue Jun 27, 2021 · 0 comments

Comments

@OhSoGood
Copy link

OhSoGood commented Jun 27, 2021

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
}

@OhSoGood OhSoGood changed the title New schedule_off command (code included) hs100: new schedule_off command (code included) Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant