$ npm install imagehat
#!/usr/bin/env node
var ImageHat = require('imagehat').ImageHat
var hat = new ImageHat(0x20) // 0x20 is the I2C bus address
hat.host // get selected host
hat.host = 0 // unplug USB device
hat.host = 1 // assign USB device to host 1
hat.host = 2 // assign USB device to host 2
hat.host2Power // get power state of host 2
hat.extIn // get state of external input
hat.extOut // get state of external output
hat.extOut = 0 // turn off external output
hat.extOut = 1 // turn on external output