Skip to content

Instantly share code, notes, and snippets.

@LarsBergqvist
Created May 15, 2016 07:14
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 LarsBergqvist/b42ef1cb4bb816f4aa338f085dd25de7 to your computer and use it in GitHub Desktop.
Save LarsBergqvist/b42ef1cb4bb816f4aa338f085dd25de7 to your computer and use it in GitHub Desktop.
Helper method for sending codes with pi-switch
import pi_switch
byte0codeON = 0x55
byte0codeOFF = 0x54
byte2 = 0x15 #This is group 1
buttonToIDCodesMap = {
1: 0x15,
2: 0x45,
3: 0x51,
4: 0x54
}
def sendCode(buttonNumber,state):
idcode = buttonToIDCodesMap[buttonNumber]
byte0code = byte0codeON
if state == 'off':
byte0code = byte0codeOFF
code = (byte2 << 16) | (idcode << 8) | byte0code
print(format(code,'000000x'))
sender = pi_switch.RCSwitchSender()
sender.enableTransmit(0)
sender.sendDecimal(code,24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment