Linux/CUPS script for turning on printer

Plugwise Forum about Plugwise devices and the Source software.
Post Reply
Tozz
Member
Member
Posts: 95
Joined: Sun Oct 28, 2007 5:20 pm
Location: Netherlands

Linux/CUPS script for turning on printer

Post by Tozz »

I created a little script that checks my CUPS printer spool for jobs that are queued. If a job is queued my printer is probably off and I use HomeSeer to turn it on. Can be modified to use Plugwise Source webserver just as easy. My printer is connected to a Plugwise plug, but this should work for any other device module in HomeSeer.

Code: Select all

#!/bin/bash
#
# My HP4700 printer uses 20 Watts in "powersave" mode.
# this is roughly 175 kWh a year. Money better spend
# elsewhere. 
#
# We use a Plugwise (www.plugwise.com) module to turn 
# the printer on/off. Any HomeSeer enabled device
# (X10, ZWave, etc) can be used.
#
# Variables
# CUPSURL = IP/hostname of CUPS server
# PRINTER = CUPS printer device
# DEVICE = HomeSeer Device ID
# HSURL = IP/hostname of HomeSeer
#
CUPSURL=192.168.0.250
PRINTER=HP4700
DEVICE=5473
HSURL=192.168.0.62
#
#
#
#
#
# Create a temporary file
TMPFILE=`mktemp`
#
# Download CUPS data from this printer
wget http://$CUPSURL:631/printers/$PRINTER -O $TMPFILE -q
#
# Do a count on string "pending since". 1 for each job
QUEUESIZE=`cat $TMPFILE | grep "pending since" | wc -l`
#
# If queuesize is larger then 0 there is a print job queued
# then turn printer on.
if [ $QUEUESIZE -gt 0 ];
then
  # Turn device on.
  wget --post-data "bookmark=$DEVICE&IFrameRef=$DEVICE&ref_page=stif&control_device=$DEVICE&action_on=On&selectdim=0" http://$HSURL/stif -O /dev/null -q
fi

#
# Delete temporary file
rm $TMPFILE
jakkes
Member
Member
Posts: 167
Joined: Sat Oct 10, 2009 2:09 pm
Location: Netherlands

Linux/CUPS script for turning on printer

Post by jakkes »

Does anybody know to script like above for a windows XP/Vista or Windows 2003 Server?
Alexander
Global Moderator
Global Moderator
Posts: 1532
Joined: Sat Mar 10, 2007 11:19 pm
Location: Netherlands

Linux/CUPS script for turning on printer

Post by Alexander »

And than for HS you mean?

Alexander
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Linux/CUPS script for turning on printer

Post by Bwired »

Useful smart script!
Yep those HP printers really suck when it comes to energy consumption, I have a small HP printer which takes 12 watt when its off [:(!] So I switch it off too.

<hr noshade size="1"><font size="1">Pieter Knuvers
http://www.bwired.nl <i>Online House in the netherlands. Domotica, Home Automation.</i></font id="size1">
Tozz
Member
Member
Posts: 95
Joined: Sun Oct 28, 2007 5:20 pm
Location: Netherlands

Re: Linux/CUPS script for turning on printer

Post by Tozz »

Do you happen to know if HP printers do anything special when you flick the switch on the printer itself? When i turn it off using the switch it seems to do 'something'. It makes some noise before it actually goes off. So I'm wondering if it might be a bad idea to turn it off by cutting power.

I have a HP 4700 DTN printer.
jakkes
Member
Member
Posts: 167
Joined: Sat Oct 10, 2009 2:09 pm
Location: Netherlands

Re: Linux/CUPS script for turning on printer

Post by jakkes »

Finaly....., i have a linux box.....

Now i would like to use this script, but where do i place it? And how to run it?

I am a linux newbie, please stay friendly....
jheerink
Member
Member
Posts: 66
Joined: Sat Apr 18, 2009 10:16 pm
Location: Netherlands
Contact:

Re: Linux/CUPS script for turning on printer

Post by jheerink »

I don't know for the HP4700 but i;am sure the older HP laserprinters (4500 fi)
need to cooldown after a print job, So when you switch it off it will continue to run
a while. To prevent the fuser from overheating. If you would switch it off with a plugwise
it could be damaged because it can,t finish the coolcycle.
Post Reply

Return to “Plugwise Forum”