Skip to content

Instantly share code, notes, and snippets.

@ebith
Last active August 4, 2019 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebith/640a23f7fefe4464a1dc4f68a5272260 to your computer and use it in GitHub Desktop.
Save ebith/640a23f7fefe4464a1dc4f68a5272260 to your computer and use it in GitHub Desktop.
mackerel plugin for UPS-Lite
#!/usr/bin/env python3
import time
import smbus
i2c = smbus.SMBus(1)
addr=0x36
data = i2c.read_i2c_block_data(addr, 0x04, 2)
capacity = int((data[0] << 8 | data[1]) / 256)
print(f'battery.capacity\t{capacity}\t{time.time()}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment