def main(): parser = argparse.ArgumentParser(description='Sends/Receives a decimal code via a 433/315MHz GPIO device') parser.add_argument('-d', dest='direction', type=int, default=2, help="Send (1) or Receive (2) (Default: 2)") parser.add_argument('-g', dest='gpio', type=int, default=17, help="GPIO pin (Default: 17)") # Send-specific commands parser.add_argument('-c', dest='code', type=int, required=False, help="Decimal code to send") parser.add_argument('-p', dest='pulselength', type=int, default=None, help="Pulselength (Default: 350)") parser.add_argument('-t', dest='protocol', type=int, default=None, help="Protocol (Default: 1)") args = parser.parse_args() if args.direction == 1: rfdevice = RFDevice(args.gpio) rfdevice.enable_tx() if args.protocol: protocol = args.protocol else: protocol = "default" if args.pulselength: pulselength = args.pulselength else: pulselength = "default" print(str(args.code) + " [protocol: " + str(protocol) + ", pulselength: " + str(pulselength) + "]") rfdevice.tx_code(args.code, args.protocol, args.pulselength) rfdevice.cleanup() elif args.direction == 2: rfdevice = RFDevice(args.gpio) rfdevice.enable_rx() timestamp = None print("Listening for codes on GPIO " + str(args.gpio)) try: while True: if rfdevice.rx_code_timestamp != timestamp: timestamp = rfdevice.rx_code_timestamp print(str(rfdevice.rx_code) + " [pulselength " + str(rfdevice.rx_pulselength) + ", protocol " + str(rfdevice.rx_proto) + "]") time.sleep(0.01) except KeyboardInterrupt: print("Keyboard Interupt") finally: rfdevice.cleanup() else: print("Invalid option: '{opt}'. " "You may either Send (1) or Receive (2). ".format( opt=args.direction))
class Transmit433MHz: """Transmit/Receive 433MHz commands""" def __init__(self, pin, protocol=1, pulse_length=189): self.device = None self.pin = pin self.protocol = protocol self.pulse_length = pulse_length self.num = 0 self.timestamp = None def enable_receive(self): try: self.device = RFDevice(self.pin) self.device.enable_rx() self.num = 0 except Exception as err: logger.exception( "{cls} raised an exception when enabling receiving: " "{err}".format(cls=type(self).__name__, err=err)) def receive_available(self): try: if self.device.rx_code_timestamp != self.timestamp: self.timestamp = self.device.rx_code_timestamp command = self.device.rx_code pulse_length = self.device.rx_pulselength protocol = self.device.rx_proto return self.num, command, pulse_length, protocol return 0, 0, 0, 0 except Exception as err: logger.exception( "{cls} raised an exception when receiving: " "{err}".format(cls=type(self).__name__, err=err)) def transmit(self, cmd): try: self.device = RFDevice(self.pin) self.device.enable_tx() self.device.tx_code(cmd, self.protocol, self.pulse_length) self.cleanup() except Exception as err: logger.exception( "{cls} raised an exception when transmitting: " "{err}".format(cls=type(self).__name__, err=err)) def cleanup(self): self.device.cleanup()
sleep(2) showLCD('Training program', slave[6]+' started...') sleep(10) defaultLCD() try: db = pymysql.connect( config['database']['hostname'], config['database']['username'], config['database']['password'], config['database']['database'] ) except: print("Error: MySQL connection failed, program start failed") lcd.lcd_clear() oled.cls() oled.display() GPIO.cleanup() db.close() rfdevice.cleanup() rfsend.cleanup() mqtt.loop.stop() sys.exit(1) cursor = db.cursor() punmqtt = PunMQTT('Punisher') punmqtt.run( config, logger, tordevices, cursor ) showLogo() defaultLCD() try: while True: rfid()
class Plugin(plugin.Plugin): """ plugin for rf433_receive """ def init(self): """ initialize """ self.rfdevice = None signal.signal(signal.SIGINT, self.exithandler) self.rfdevice = RFDevice(27) def exithandler(signal, frame): """ exit signal handler """ self.rfdevice.cleanup() def setTuyaStatus(self, devid, newstatus, switch=1): done = False for attempt in ("first", "second", "third"): try: logger.logDebug("%s try to set status on %s" % (attempt, devid)) key = CFG.DEVICES[devid] tuyadev = pytuya.OutletDevice(devid, key[0], key[1]) status = tuyadev.status()['dps'][str(switch)] if status == newstatus: logger.logDebug("status already set, skipping %s" % devid) break tuyadev.set_status(newstatus, switch) time.sleep(CFG.SLEEP_INTERVAL) status = tuyadev.status()['dps'][str(switch)] if status == newstatus: logger.logDebug("status successfully set %s" % devid) done = True except: logger.logError("failed to set status of %s" % devid) if done: break def run(self): """ plugin main """ self.rfdevice.enable_rx() timestamp = None lastcode = None while True: if self.rfdevice.rx_code_timestamp != timestamp: try: if lastcode == self.rfdevice.rx_code and self.rfdevice.rx_code_timestamp < timestamp + 1000000: timestamp = self.rfdevice.rx_code_timestamp logger.logDebug("rf433_receive skipping: %s" % str(timestamp)) time.sleep(CFG.SLEEP_INTERVAL) continue except: logger.logDebug("rf433_receive passing: %s" % str(timestamp)) logger.logDebug("rf433_receive timestamp: %s" % str(timestamp)) timestamp = self.rfdevice.rx_code_timestamp lastcode = self.rfdevice.rx_code logger.logDebug( "rf433_receive code: %s length %s protocol: %s" % (str(self.rfdevice.rx_code), str(self.rfdevice.rx_pulselength), str(self.rfdevice.rx_proto))) keycode = str(self.rfdevice.rx_code) if keycode in CFG.RF433.keys() and CFG.RF433[keycode][0]: if len(CFG.RF433[keycode]) == 2: self.setTuyaStatus(CFG.RF433[keycode][0], CFG.RF433[keycode][1]) if len(CFG.RF433[keycode]) == 3: self.setTuyaStatus(CFG.RF433[keycode][0], CFG.RF433[keycode][1], CFG.RF433[keycode][2]) time.sleep(CFG.SLEEP_INTERVAL) else: self.sendEvents(EVENT.RF433_PRESSED % self.rfdevice.rx_code) time.sleep(CFG.SLEEP_INTERVAL) rfdevice.cleanup() eventhandler = {} def receiveData(self, data_dict): """ handle received data :param data_dict: received data """ # try autoresponse first self.autoResponder(data_dict) if "method" in data_dict.keys(): # cmds if data_dict["method"] == METHOD.CMD and data_dict["params"][ "target"] == self.plugin_name: for cmdstring in data_dict["params"]["cmds"]: try: path = self.items if not cmdstring.split( CONST.DELIMITER)[0] in cfg.MY_PLACES: continue for p in cmdstring.split(CONST.DELIMITER): path = path[p] code = path self.tasker.putTask(code) except Exception as err: logger.logError("Failed to run command %s: %s" % (str(cmdstring), str(err))) # events if data_dict["method"] == METHOD.EVENT: for event in data_dict["params"]["events"]: try: if event in self.eventhandler.keys(): self.eventhandler[event](self) except Exception as err: logger.logError( "Failed to handle event '%s' error: %s" % (event, str(err)))
def main(): parser = argparse.ArgumentParser( description='Sends/Receives a decimal code via a 433/315MHz GPIO device' ) parser.add_argument('-d', dest='direction', type=int, default=2, help="Send (1) or Receive (2) (Default: 2)") parser.add_argument('-g', dest='gpio', type=int, default=17, help="GPIO pin (Default: 17)") # Send-specific commands parser.add_argument('-c', dest='code', type=int, required=False, help="Decimal code to send") parser.add_argument('-p', dest='pulselength', type=int, default=None, help="Pulselength (Default: 350)") parser.add_argument('-t', dest='protocol', type=int, default=None, help="Protocol (Default: 1)") args = parser.parse_args() if args.direction == 1: rfdevice = RFDevice(args.gpio) rfdevice.enable_tx() if args.protocol: protocol = args.protocol else: protocol = "default" if args.pulselength: pulselength = args.pulselength else: pulselength = "default" print( str(args.code) + " [protocol: " + str(protocol) + ", pulselength: " + str(pulselength) + "]") rfdevice.tx_code(args.code, args.protocol, args.pulselength) rfdevice.cleanup() elif args.direction == 2: rfdevice = RFDevice(args.gpio) rfdevice.enable_rx() timestamp = None print("Listening for codes on GPIO " + str(args.gpio)) try: while True: if rfdevice.rx_code_timestamp != timestamp: timestamp = rfdevice.rx_code_timestamp print( str(rfdevice.rx_code) + " [pulselength " + str(rfdevice.rx_pulselength) + ", protocol " + str(rfdevice.rx_proto) + "]") time.sleep(0.01) except KeyboardInterrupt: print("Keyboard Interupt") finally: rfdevice.cleanup() else: print("Invalid option: '{opt}'. " "You may either Send (1) or Receive (2). ".format( opt=args.direction))
def main(): parser = argparse.ArgumentParser( description= 'Receives a decimal code via a 433/315MHz GPIO device and send it to an MQTT broker' ) parser.add_argument('-g', dest='gpio', type=int, default=27, help="GPIO pin (Default: 27)") parser.add_argument('-m', dest='mqtt_broker_addr', type=str, default='127.0.0.1', help="Address of the MQTT broker (default: 127.0.0.1)") parser.add_argument('-p', dest='mqtt_broker_port', type=int, default=1883, help="Port of the MQTT broker (default: 1883)") parser.add_argument('-t', dest='mqtt_topic', type=str, default='rc', help="Topic to send the messages to (default: rc)") parser.add_argument( '-r', dest='rate_limit', type=int, default=200, help= "Rate limit in milliseconds to filter burst of codes sent by RF remotes (default: 200)" ) parser.add_argument('-v', dest='verbose', action='store_true', help="More verbose logs") args = parser.parse_args() if args.verbose: log.setLevel(logging.DEBUG) MQTT_CONNECT_TIMEOUT = 120 timeout = 0 while timeout < MQTT_CONNECT_TIMEOUT: try: mqtt_client = mqtt_connect(args.mqtt_broker_addr, args.mqtt_broker_port) except ConnectionRefusedError: log.info( "Could not connect to mqtt broker, Trying again in 5 sec...") time.sleep(5) timeout += 5 continue break signal.signal(signal.SIGINT, exithandler) rfdevice = RFDevice(args.gpio) rfdevice.enable_rx() timestamp = None previous_signal = (0, 0) log.info("Listening for codes on GPIO " + str(args.gpio)) while True: if rfdevice.rx_code_timestamp != timestamp: timestamp = rfdevice.rx_code_timestamp code = rfdevice.rx_code protocol = rfdevice.rx_proto pulselength = rfdevice.rx_pulselength log.debug("code: {}, protocol: {}, timestamp: {}, pulselength: {}". format( code, protocol, timestamp, pulselength, )) previous_code, previous_timestamp = previous_signal min_delta_t = args.rate_limit * 1000 if code == previous_code: delta_t = timestamp - previous_timestamp if delta_t < min_delta_t: log.debug( "Rate limiting, got same code: {} and delta t: {}/{}". format( code, delta_t, min_delta_t, )) continue mqtt_send(mqtt_client, args.mqtt_topic, str(code)) previous_signal = (code, timestamp) time.sleep(0.01) rfdevice.cleanup()
import argparse import logging import time from RPi import GPIO from rpi_rf import RFDevice def rx_callback(inV): print("rsCallback",inV) rfRX = RFDevice(27) rfRX.enable_rx() timestamp = None #GPIO.add_event_detect(17, GPIO.BOTH) GPIO.add_event_callback(27, rx_callback) while True: if rfRX.rx_code_timestamp != timestamp: timestamp = rfRX.rx_code_timestamp logging.info("RX:::"+str(rfRX.rx_code) + " [pulselength " + str(rfRX.rx_pulselength) + ", protocol " + str(rfRX.rx_proto) + "]") time.sleep(0.01) #print("waiting..",rfRX.rx_code_timestamp) rfRX.cleanup()
def main(): #Config config = configparser.ConfigParser() config.read('config.ini') cMqtt = config['MQTT'] cGPIO = config['GPIO'] cDevices = config['DEVICES'] #MQTT client = mqtt.Client() client.on_connect = on_connect ##client.on_message = on_message client.username_pw_set(cMqtt['username'], cMqtt['password']) client.connect(cMqtt['host']) client.loop_start() # RF signal.signal(signal.SIGINT, exithandler) rfdevice = RFDevice(int(cGPIO['pin'])) rfdevice.enable_rx() timestamp = None logging.info("Listening for codes on GPIO " + str(cGPIO['pin'])) for device, name in cDevices.items(): client.publish( "homeassistant/device_automation/rpi-433-mqtt/" + str(device) + "/config", json.dumps({ "automation_type": "trigger", "topic": "homeassistant/device_automation/rpi-433-mqtt/" + str(device) + "/topic", "type": "click", "subtype": "on", "payload": "on", "device": { "identifiers": str(device), "name": str(name), "model": "raspberryPI" } })) while True: if rfdevice.rx_code_timestamp != timestamp: timestamp = rfdevice.rx_code_timestamp if str(rfdevice.rx_code) in cDevices: client.publish( "homeassistant/device_automation/rpi-433-mqtt/" + str(rfdevice.rx_code) + "/topic", "on") logging.info( str(rfdevice.rx_code) + " [pulselength " + str(rfdevice.rx_pulselength) + ", protocol " + str(rfdevice.rx_proto) + "]") time.sleep(0.01) rfdevice.cleanup()
class RfController: def __init__(self): self.rfReceiver = RFDevice(27) self.rfReceiver.enable_rx() self.rfTransmitter = RFDevice(17) self.rfTransmitter.tx_repeat = 20 self.timestamp = None def exithandler(self, signal, frame): self.rfReceiver.cleanup() self.rfTransmitter.cleanup() sys.exit(0) async def receive(self, timeout=None, expected_response=None): start = datetime.now() while True: if self.rfReceiver.rx_code_timestamp != self.timestamp: if self.valid_rx(self.rfReceiver.rx_pulselength, self.rfReceiver.rx_proto): self.timestamp = self.rfReceiver.rx_code_timestamp if self.rfReceiver.rx_code == expected_response: break elif not expected_response: break if timeout: diff = (datetime.now() - start).seconds if diff > timeout: break await asyncio.sleep(0.01) return self.rfReceiver.rx_code def valid_rx(self, pulse_length, protocol): if 349 <= pulse_length <= 354 and protocol == 1: return True else: return False async def get_response(self, timeout=None, expected_response=None): return await self.receive(timeout, expected_response) async def send(self, data): try: log_info_message('Sending ' + str(data)) self.rfReceiver.disable_rx() await asyncio.sleep(0.01) self.rfTransmitter.enable_tx() await asyncio.sleep(0.01) self.rfTransmitter.tx_code(data, 1) await asyncio.sleep(0.01) self.rfTransmitter.disable_tx() await asyncio.sleep(0.01) self.rfReceiver.enable_rx() log_info_message('Sent Data') await asyncio.sleep(1) except Exception as e: print('Exception while sending - retrying: ' + str(e)) await self.send(data) def exit(self): self.rfTransmitter.cleanup() self.rfReceiver.cleanup() return def disable_receiver(self): self.rfReceiver.disable_rx()
parser.add_argument('-m', '--mode', default='rf', choices=['rf', 'sp'], help="Use rpi_rf or subcommand") parser.add_argument('-d') args = parser.parse_args() logger.debug("Arguments: socket=%s, command=%s method=%s", args.socket, args.cmd, args.mode) if args.d: logger.info("Sending Decimal code {}".format(args.d)) try: rf_device = RFDevice(GPIO_PIN) rf_device.enable_tx() rf_device.tx_code(int(args.d)) except: logger.exception("Error while sending code to socket using rpi_rf") finally: rf_device.cleanup() elif args.socket: if args.cmd == 'on': if args.mode == 'rf': turn_socket_on(args.socket, "rpi_rf") else: turn_socket_on(args.socket, "subprocess") else: if args.mode == 'rf': turn_socket_off(args.socket, "rpi_rf") else: turn_socket_off(args.socket, "subprocess") sys.exit() print(123)
def switch(code): print('') rfdevice = RFDevice(17) rfdevice.enable_tx() rfdevice.tx_code(code, 1, 350) rfdevice.cleanup()
trans = RFDevice(TRANSMIT_PIN) trans.enable_tx() trans.tx_repeat = 10 parser = argparse.ArgumentParser() parser.add_argument("--on") parser.add_argument("--off") args = parser.parse_args() print(args) if args.on: if args.on == "main": trans.tx_code(ON_MAIN, PROTOCOL, TRANS_LENGTH, 24) trans.cleanup() elif args.on == "sec": trans.tx_code(ON_SEC, PROTOCOL, TRANS_LENGTH, 24) trans.cleanup() elif args.on == "lamp": trans.tx_code(ON_LAMP, PROTOCOL, TRANS_LENGTH, 24) elif args.on == "all": trans.tx_code(ON_MAIN, PROTOCOL, TRANS_LENGTH, 24) trans.tx_code(ON_SEC, PROTOCOL, TRANS_LENGTH, 24) trans.tx_code(ON_LAMP, PROTOCOL, TRANS_LENGTH, 24) trans.cleanup() if args.off: if args.off == "main": trans.tx_code(OFF_MAIN, PROTOCOL, TRANS_LENGTH, 24) trans.cleanup()
class Plugin(plugin.Plugin): """ plugin for rf433_receive """ def init(self): """ initialize """ self.rfdevice = None signal.signal(signal.SIGINT, self.exithandler) self.rfdevice = RFDevice(27) def exithandler(signal, frame): """ exit signal handler """ self.rfdevice.cleanup() def setTuyaStatus(self, devid, newstatus, switch=1): done = False for attempt in ("first", "second", "third"): try: logger.logDebug("%s try to set status on %s" % (attempt, devid)) key = CFG.DEVICES[devid] tuyadev = pytuya.OutletDevice(devid, key[0], key[1]) status = tuyadev.status()['dps'][str(switch)] if status == newstatus: logger.logDebug("status already set, skipping %s" % devid) break tuyadev.set_status(newstatus, switch) time.sleep(CFG.SLEEP_INTERVAL) status = tuyadev.status()['dps'][str(switch)] if status == newstatus: logger.logDebug("status successfully set %s" % devid) done = True except: logger.logError("failed to set status of %s" % devid) if done: break def run(self): """ plugin main """ self.rfdevice.enable_rx() timestamp = None lastcode = None while True: if self.rfdevice.rx_code_timestamp != timestamp: try: if lastcode == self.rfdevice.rx_code and self.rfdevice.rx_code_timestamp < timestamp + 1000000: timestamp = self.rfdevice.rx_code_timestamp logger.logDebug("rf433_receive skipping: %s" % str(timestamp)) time.sleep(CFG.SLEEP_INTERVAL) continue except: logger.logDebug("rf433_receive passing: %s" % str(timestamp)) logger.logDebug("rf433_receive timestamp: %s" % str(timestamp)) timestamp = self.rfdevice.rx_code_timestamp lastcode = self.rfdevice.rx_code logger.logDebug("rf433_receive code: %s length %s protocol: %s" % (str(self.rfdevice.rx_code), str(self.rfdevice.rx_pulselength), str(self.rfdevice.rx_proto))) keycode = str(self.rfdevice.rx_code) if keycode in CFG.RF433.keys() and CFG.RF433[keycode][0]: if len(CFG.RF433[keycode]) == 2: self.setTuyaStatus(CFG.RF433[keycode][0], CFG.RF433[keycode][1]) if len(CFG.RF433[keycode]) == 3: self.setTuyaStatus(CFG.RF433[keycode][0], CFG.RF433[keycode][1], CFG.RF433[keycode][2]) time.sleep(CFG.SLEEP_INTERVAL) else: self.sendEvents(EVENT.RF433_PRESSED % self.rfdevice.rx_code) time.sleep(CFG.SLEEP_INTERVAL) rfdevice.cleanup() eventhandler = { } def receiveData(self, data_dict): """ handle received data :param data_dict: received data """ # try autoresponse first self.autoResponder(data_dict) if "method" in data_dict.keys(): # cmds if data_dict["method"] == METHOD.CMD and data_dict["params"]["target"] == self.plugin_name: for cmdstring in data_dict["params"]["cmds"]: try: path = self.items if not cmdstring.split(CONST.DELIMITER)[0] in cfg.MY_PLACES: continue for p in cmdstring.split(CONST.DELIMITER): path = path[p] code = path self.tasker.putTask(code) except Exception as err: logger.logError("Failed to run command %s: %s" % (str(cmdstring), str(err))) # events if data_dict["method"] == METHOD.EVENT: for event in data_dict["params"]["events"]: try: if event in self.eventhandler.keys(): self.eventhandler[event](self) except Exception as err: logger.logError("Failed to handle event '%s' error: %s" % (event, str(err)))
def handle_rpirfoffcorner(self, message): rfdevice = RFDevice(17) #default gpio pin rfdevice.enable_tx() rfdevice.tx_code(267724, 1, 173) #stand code, protocol, pulse rfdevice.cleanup()
def handle_rpirfoffshelf(self, message): rfdevice = RFDevice(17) #default gpio pin rfdevice.enable_tx() rfdevice.tx_code(267580, 1, 172) #globes code, protocol, pulse rfdevice.cleanup()
from rpi_rf import RFDevice rfdevice = None # pylint: disable=unused-argument def exithandler(signal, frame): rfdevice.cleanup() sys.exit(0) logging.basicConfig(level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S', format='%(asctime)-15s - [%(levelname)s] %(module)s: %(message)s', ) parser = argparse.ArgumentParser(description='Receives a decimal code via a 433/315MHz GPIO device') parser.add_argument('-g', dest='gpio', type=int, default=27, help="GPIO pin (Default: 27)") args = parser.parse_args() signal.signal(signal.SIGINT, exithandler) rfdevice = RFDevice(args.gpio) rfdevice.enable_rx() timestamp = None logging.info("Listening for codes on GPIO " + str(args.gpio)) while True: if rfdevice.rx_code_timestamp != timestamp: timestamp = rfdevice.rx_code_timestamp logging.info(str(rfdevice.rx_code) + " [pulselength " + str(rfdevice.rx_pulselength) + ", protocol " + str(rfdevice.rx_proto) + "]") time.sleep(0.01) rfdevice.cleanup()
help="GPIO pin (Default: 17)") parser.add_argument('-p', dest='pulselength', type=int, default=None, help="Pulselength (Default: 350)") parser.add_argument('-t', dest='protocol', type=int, default=None, help="Protocol (Default: 1)") args = parser.parse_args() rfdevice = RFDevice(args.gpio) rfdevice.enable_tx() if args.protocol: protocol = args.protocol else: protocol = "default" if args.pulselength: pulselength = args.pulselength else: pulselength = "default" logging.info( str(args.code) + " [protocol: " + str(protocol) + ", pulselength: " + str(pulselength) + "]") rfdevice.tx_code(args.code, args.protocol, args.pulselength) rfdevice.cleanup()
class DustyBridge(Bridge): def __init__(self, driver, max_switches, pca, config): super().__init__(driver, "Dusty Bridge") self.config = config # Setup RF Transmitter self.rf = RFDevice(self.config.rf.pin) self.rf.enable_tx() self.rf.tx_repeat = self.config.rf.tx_repeat self.rf.tx_proto = self.config.rf.tx_proto self.dust_collector_on = False self.gate_to_close = None self.active_switch = None self.gate_close_counter = -1 self.servos = {} for pin in range(max_switches): self.servos[pin] = servo.ContinuousServo(pca.channels[pin], min_pulse=self.config.servo.min_pulse, max_pulse=self.config.servo.max_pulse) self.add_accessory(DustySwitch(self, pin, driver, "Dusty Switch #"+str(pin))) shutdown_switch = ShutdownSwitch(driver,"Halt") self.add_accessory(shutdown_switch) def turn_on(self, switch): if self.active_switch: self.close_gate(self.active_switch.pin) self.active_switch.power_down() self.gate_close_counter = 0 self.gate_to_close = None self.active_switch = switch self.open_gate(self.active_switch.pin) self.turn_on_dust_collector() def turn_off(self, switch): self.gate_to_close = switch.pin self.active_switch = None self.gate_close_counter = self.config.dusty.gate_close_pause self.turn_off_dust_collector() pass def close_gate(self, pin): self.servos[pin].throttle = self.config.servo.throttle time.sleep(self.config.servo.close_time) self.servos[pin].throttle = 0 logger.info("Close Gate #" + str(pin)) def open_gate(self, pin): self.servos[pin].throttle = self.config.servo.throttle * -1 time.sleep(self.config.servo.open_time) self.servos[pin].throttle = 0 logger.info("Open Gate #" + str(pin)) def turn_on_dust_collector(self): if not self.dust_collector_on: self.dust_collector_on = True if self.config.rf.enabled: self.rf.tx_code(self.config.rf.on_code) else: logger.info("rf disbaled") logger.info("turn on dust collector") def turn_off_dust_collector(self): self.dust_collector_on = False if self.config.rf.enabled: self.rf.tx_code(self.config.rf.off_code) else: logger.info("rf disbaled") logger.info("turn off dust collector") def stop(self): self.rf.cleanup() @Accessory.run_at_interval(1) def run (self): if self.gate_close_counter > 0: self.gate_close_counter -= 1 logger.info("counting down "+str(self.gate_close_counter)) if self.gate_to_close != None and self.gate_close_counter == 0: self.close_gate(self.gate_to_close) self.gate_to_close = None