def shortPoll(self): # Update Watering Status if self.ready: # LOGGER.info("Updating Watering Status") for node in self.nodes: if self.nodes[node].address != self.address: for gw in self.data['devices']: for tl in gw['taplinker']: if tl['taplinkerId'][0:8].lower() == self.nodes[node].address: if tl['status'] == 'Connected': link_tap = linktap.LinkTap(self.username, self.apiKey) watering_status = link_tap.get_watering_status(tl['taplinkerId']) # print(watering_status) try: if watering_status['status'] is not None: if watering_status['status']['onDuration']: self.nodes[node].setDriver('GV1', 1) self.nodes[node].setDriver('GV2', watering_status['status']['onDuration']) if watering_status['status']['total']: self.nodes[node].setDriver('GV3', watering_status['status']['total']) watering_total = int(watering_status['status']['total']) watering_duration = int(watering_status['status']['onDuration']) watering_elapsed = watering_total - watering_duration self.nodes[node].setDriver('GV4', watering_elapsed) else: self.nodes[node].setDriver('GV1', 0) self.nodes[node].setDriver('GV2', 0) self.nodes[node].setDriver('GV3', 0) self.nodes[node].setDriver('GV4', 0) except TypeError: pass else: pass
def instantOff(self, command): taplinker = command.get('address') + self.dev_suffix gateway = self.primary + self.dev_suffix duration = 0 action = False eco = False lt = linktap.LinkTap(self.controller.username, self.controller.apiKey) lt.activate_instant_mode(gateway, taplinker, action, duration, eco) self.setDriver('GV1', 0) self.setDriver('GV2', duration) self.setDriver('GV3', duration)
def get_link_tap_devices(self): lt = linktap.LinkTap(self.username, self.apiKey) all_devices = lt.get_all_devices() if all_devices == 'error': LOGGER.info("get_link_tap_devices: The minimum interval of calling this API is 5 minutes.") self.data = None self.ready = False return False elif all_devices is None: LOGGER.info("Get all devices failed") self.data = None self.ready = False return False else: self.data = all_devices self.ready = True return True
def instantOn(self, command): val = command.get('value') taplinker = command.get('address') + self.dev_suffix gateway = self.primary + self.dev_suffix duration = int(val) # if duration == 0: # action = False # else: # action = True action = True eco = False lt = linktap.LinkTap(self.controller.username, self.controller.apiKey) lt.activate_instant_mode(gateway, taplinker, action, duration, eco) self.setDriver('GV1', 1) self.setDriver('GV2', duration) self.setDriver('GV3', duration)
def monthMode(self, command): taplinker = command.get('address') + self.dev_suffix gateway = self.primary + self.dev_suffix lt = linktap.LinkTap(self.controller.username, self.controller.apiKey) lt.activate_month_mode(gateway, taplinker)