Created
November 3, 2016 11:50
-
-
Save LarsBergqvist/19f69213cab60d55640429c1f70d6d06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pi_switch | |
from mylogger import logger | |
byte0codeON = 0x55 | |
byte0codeOFF = 0x54 | |
groupToCodeMap = { | |
1: 0x15, | |
2: 0x45, | |
3: 0x51, | |
4: 0x54 | |
} | |
buttonToCodeMap = { | |
1: 0x15, | |
2: 0x45, | |
3: 0x51, | |
4: 0x54 | |
} | |
def sendCode(groupNumber,buttonNumber,state): | |
if not buttonNumber in buttonToCodeMap.keys(): | |
return | |
if not groupNumber in groupToCodeMap.keys(): | |
return | |
numberCode = buttonToCodeMap[buttonNumber] | |
groupCode = groupToCodeMap[groupNumber] | |
byte0code = byte0codeON | |
if state == 'off': | |
byte0code = byte0codeOFF | |
code = (groupCode << 16) | (numberCode << 8) | byte0code | |
logger.info("Sending code: " + 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