NAS

Switching power outlets with CUPS/sispmctl

3 2460
tkaiser  
Edited by tkaiser at Wed Nov 26, 2014 05:37

The following is an approach to switch the sockets of USB-connected cheap EnerGenie EG-PM2, EG-PMS, EG-PMS2 socket outlets via CUPS and sispmctl:



The idea behind: Use your ARM board as print server and easily switch on laserprinters when they're needed and switch them off after printing by sending any print job to a special queue that switches the printer's power socket off (don't do that with inkjets or any other device that needs to be turned off safely!)

Here you can find the backend that does the job: http://pastebin.com/S8n7jN2S (read/understand the comments in the script's header carefully. The installation details are outlined there)

Prerequisits (replace "apt-get install" with "yum install" or "pacman -S" when your distro is not Debian based):
  1. apt-get install cups sispmctl
  2. chmod u+s /usr/bin/sispmctl
  3. cupsctl --remote-admin
Copy the Code
Afterwards you can access the CUPS webinterface using https://$IP-ADDRESS-OF-YOUR-BANANA:631/admin/ (you might want to disable remote access afterwards via the web interface itself or by 'cupsctl --no-remote-admin' as root). If there are SiS-PM power outlets connected they will be listed when you access "Add Printer". In my case 2 devices are connected with different serial numbers (01:01:51:45:0b and 01:01:51:23:cb).

Imagine there is a LaserJet HP4500 connected to the fourth socket of the first power outlet then we would need two pseudo printers to switch the printer on and off:







Don't choose a PPD but use 'raw' as printer type, assign any name you want and take care that you enable the 'Share This Printer' checkbox when you want to use this 'pseudo printer' from other machines (this is the real purpose of this whole setup since otherwise you could use sispmctl locally). To create a 'switch the device off' pseudo printer you just choose the right 'device' and then it's exactly the same procedure:



The printer queue names and descriptions do not matter at all since socket and serial number are encoded in the queue's so called 'Device URI' starting with sispmctlcups:// in our case:
  1. root@bananas ~ # lpstat -t
  2. scheduler is running
  3. no system default destination
  4. device for power_off_laserprinter: sispmctlcups://01_01_51_45_0b-4-off
  5. device for switch_on_laserjet: sispmctlcups://01_01_51_45_0b-4-on
  6. device for Switch_Socket_4_on_second_SiS-PM_on: sispmctlcups://01_01_51_23_cb-4-on
  7. ...
Copy the Code


You could not only switch printers on and off using CUPS but other connected devices as well (sounds weird in the first place but the good news is that CUPS supports fine grained authentication for different queues so you can just allow specific machines/users in your network to switch devices connected to the print server). And using eg. Tea4CUPS you could create CUPS queues that consist of two queues: The one that accesses the printer and prints the job and another sispmctl queue that leads automagically to a powered on printer if it was switched off before (you can also use 'prehooks' with Tea4CUPS that switch the printer on prior to printing and then use just a 'switch the printer off when finished' queue to power-off manually over the network).
mega-hz  
Hello,

i made a PI-Printserver using cups and tea4cups and need some help:

tea4cups should turn on a relays before printing to the Laser and turn off the relays after printing with prehook and posthook.
I made two little scripts to switch an gpio and they are working fine.
But i canT get it running with tea4cups.
Maybe i made an error so please help me?

Tis is my printers.conf:


# Printer configuration file for CUPS v1.7.5
# Written by cupsd
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
<Printer Canon_iP7200_series>
UUID urn:uuid:821b37ce-6a4f-3c31-6099-a3aec50e5cd7
Info Canon iP7200 series
Location print-server
DeviceURI tea4cups:usb://Canon/iP7200%20series?serial=088A3E
State Idle
StateTime 1501951645
Type 36892
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>
<Printer FS-1020D>
UUID urn:uuid:3a66e55b-0c8d-3ac9-7a46-da5672b9dac8
Info Kyocera FS-1020D
Location print-server
DeviceURI tea4cups:usb://Kyocera/FS-1020D?serial=XAX5777229
State Stopped
StateMessage Unplugged or turned off
StateTime 1502138997
Reason paused
Type 4116
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>



And this is my tea4cups.conf:


[FS-1020D]
prehook : /home/pi/relays_on.py
posthook : /home/pi/relays_off.py

What is wrong?

Thank you very much for help!

mega-hz  
This works:

[global]
prehook : /home/pi/relays_on.py
posthook : /home/pi/relays_off.py

why not on [FS-1020D] ?

coach outlet online
uggs
ray bans
michael kors uk
canada goose jackets
michael kors outlet online
canada goose jackets
ralph lauren sale
canada goose coats
louis vuitton factory outlet
uggs outlet
burberry outlet online
coach factory outlet online
moncler
yeezy boost
yeezy shoes
moncler coats
louis vuitton outlet store
moncler jackets
fred perry shirts
ugg boots
michael kors outlet canada
jerseys cheap
cheap air jordans
ugg outlet online
cheap ugg boots
michael kors outlet online
ugg boots
polo outlet online
pandora charms sale clearance
birkenstock shoes
longchamp bags
uggs on sale
michael kors outlet store
ray ban sunglasses discount
harden vol 1
adidas yeezy boost
birkenstock outlet
ugg boots
ugg boots
coach outlet store
moncler outlet online
salvatore ferragamo outlet
moncler uk
michael kors
red bottoms
adidas outlet online
ugg boots
uggs outlet
uggs outlet
mbt
ferragamo shoes
ralph lauren outlet online
cheap air jordans
pandora charms outlet
polo ralph lauren outlet
cheap jordan shoes
ugg outlet
adidas outlet online
salvatore ferragamo shoes
coach outlet online
coach outlet store
ugg boots
columbia sportswear outlet
mlb jerseys cheap
supreme shirts
ugg outlet
ugg australia outlet
ugg outlet
canada goose jackets
coach outlet online
ugg outlet online
pandora charms
coach outlet online
coach factory outlet online
canada goose outlet online
canada goose jackets
north face jackets
louboutin outlet
mulberry
ugg canada
canada goose jackets
coach handbags outlet
uggs outlet
adidas nmd r1
michael kors outlet store
nike outlet
michael kors handbags
ugg outlet
uggs outlet
ugg boots
canada goose parka
coach outlet online
pandora uk
canada goose outlet
louboutin outlet
fitflop sandals
birkin handbags
the north face outlet
air jordan retro
air max
michael kors outlet clearance
michael kors outlet online
moncler jacket
ugg boots outlet
canada goose outlet
ugg canada
canada goose
uggs outlet
adidas nmd runner
michael kors outlet online
north face jackets
uggs sale
coach factory outlet online
canada goose sale
cheap air jordans
michael kors outlet store
air max shoes
adidas superstar shoes
171128yueqin

You have to log in before you can reply Login | Sign Up

Points Rules