Weather updates on your HP printer's LCD

The following script uses the Python Weather API and some commands from the Printer Job Language to set the "ready message" on the LCD display of to read the current weather conditions. It should work on any networked HP printer with an LCD display and possibly some non-HP postscript printers.

#!/usr/bin/python
import pywapi # <a href="http://code.google.com/p/python-weather-api/<br />
import" title="http://code.google.com/p/python-weather-api/<br />
import">http://code.google.com/p/python-weather-api/<br />
import</a> telnetlib
import sys
 
if len(sys.argv) != 3:
  print "USAGE: python print_weather.py <ZIPCODE> <PRINTER_IP>"
  exit()
 
location_id = sys.argv[1]
printer_host = sys.argv[2]
 
forecast = pywapi.get_weather_from_google(location_id)
 
weather_str = ("%sF %s. %s:%s" % (forecast['current_conditions']['temp_f'], 
  forecast['current_conditions']['condition'],
  forecast['forecasts'][0]['day_of_week'],
  forecast['forecasts'][0]['condition']))
 
weather_str = "\x1B%%-12345X@PJL RDYMSG DISPLAY = \"%s\"\r\n\x1B%%-12345X\r\n" % (weather_str)
tn = telnetlib.Telnet(printer_host,9100)
tn.write(weather_str.encode('latin-1')) # encode to workaround this bug http://bugs.python.org/issue1772794

You can download the above script (along with the required weather api library) here: print_weather.zip

From Cygwin in Windows, Terminal in OS X, or any modern Linux/Unix, you should be able to run something like "python print_weather.py 90210 192.168.2.1" from a cronjob and it will update the display of the printer at the given IP address with weather at the given zip code