def LampCmd(self, sCmd): # Warn if lamp command is empty if (len(sCmd) < 1): self.log.warning('Server', 'Lamp command is empty!') return 'Lamp command is empty!' # Send command sender = pi_switch.RCSwitchSender() sender.enableTransmit(Config.RPi_Pin_Transmitter) sender.sendDecimal(int(sCmd), 24) # Return return 'Done!'
def init(self): """ initialize """ self.items = CFG.ITEMS_AC_SOCK self.ac_socks = pi_switch.RCSwitchSender() self.ac_socks.enableTransmit(0) self.ac_socks.setProtocol(1) self.daytime = day_time.DayTime() self.tasker = tasks.Tasks() self.tasker.setTaskHandler(self.transmitCode)
class device_handler(debounce_handler): """Publishes the on/off state requested, and the IP address of the Echo making the request. """ device1 = "device one" TRIGGERS = { device1: 52001, "device two": 52002, "device three": 52003, "device four": 52004, "device five": 52005, "device six": 52006, "device seven": 52007, "device eight": 52008, "device nine": 52009, "device ten": 52010 } CODES = { device1: { "ON": 70963, "OFF": 70972 }, "device two": { "ON": 71107, "OFF": 71116 }, "device three": { "ON": 71427, "OFF": 71436 }, "device four": { "ON": 72963, "OFF": 72972 }, "device five": { "ON": 79107, "OFF": 79116 }, "device six": { "ON": 1054003, "OFF": 1054012 }, "device seven": { "ON": 1054147, "OFF": 1054156 }, "device eight": { "ON": 1054467, "OFF": 1054476 }, "device nine": { "ON": 1056003, "OFF": 1056012 }, "device ten": { "ON": 1062147, "OFF": 1062156 } } rf = pi_switch.RCSwitchSender() rf.enableTransmit(0) rf.setPulseLength(150) #194 189 def act(self, client_address, state, name): print "State", state, "on ", name, "from client @", client_address if state: self.rf.sendDecimal(self.CODES[name]["ON"], 24) else: self.rf.sendDecimal(self.CODES[name]["OFF"], 24) return True
def __init__(self): self.sender = pi_switch.RCSwitchSender() self.sender.enableTransmit(0) self.receiver = RCSwitchReceiver() self.receiver.enableReceive(2)
import picamera import paho.mqtt.client as mqtt import pi_switch import pygame from time import sleep # Access Granted - 100 - Foto reconhecida com acc > 60% # Access Denied - 200 - # Sorry, Try Again - 300 # Wait, calling owner.. - 400 # Take pic again - 500 res = "" sender = pi_switch.RCSwitchSender() sender.enableTransmit(2) GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.OUT) pygame.mixer.init() def playsound(sound, waitsound): pygame.mixer.music.load(sound) pygame.mixer.music.set_endevent(pygame.constants.USEREVENT) pygame.mixer.music.play() while pygame.mixer.music.get_busy() == waitsound: continue # connect event def on_connect(mosq, obj, rc):
def createRF(): rf = pi_switch.RCSwitchSender() rf.enableTransmit(0) rf.setPulseLength(194) return rf