def WriteValue(self, value, options): self.value = value part_1 = int(self.value[0]) part_2 = int(self.value[1]) value_c = hex(part_1 << 8 | part_2) data.setData("rgb_flash_delay", int(value_c, 16))
def WriteValue(self, value, options): self.value = value string = "%i,%i,%i" % (int(self.value[0]), int( self.value[1]), int(self.value[2])) data.setData("rgb_single", string)
def reply_to_mentions(api, since_id): print("Retrieving mentions...") new_since_id = since_id for tweet in tweepy.Cursor(api.mentions_timeline, since_id=since_id).items(): try: new_since_id = max(tweet.id, new_since_id) if tweet.in_reply_to_status_id is not None: continue # preprocess input = tweet.text.replace('@PostbotSiemen', '').strip() rep = '@' + tweet.user.screen_name + ' ' + reply(input) if len(rep) > 280: rep = '@' + tweet.user.screen_name + ' ' + replies.generate( Template.too_long) print("Replying to " + tweet.user.screen_name) api.update_status(rep, tweet.id) data.setData('lastTweet', new_since_id) except tweepy.TweepError as e: print(e.reason) return new_since_id
def callbackIsActive(self, topic, value): if not value: self.buzzer.buzzerOff() self.alertSteal.turnOff() setData(topic, value) print(self.value())
def WriteValue(self, value, options): self.value = value string = "" chars = [] for byte in self.value: if isinstance(byte, dbus.Byte): chars.append(chr(byte)) string = string.join(chars) data.setData("weather_city", string)
def callback(self, topic, value): state = getData(topic) if value != state and isinstance(value, int): if value == self.minAngle: self.closeDoor() setData(topic, value) elif value == self.maxAngle: self.openDoor() setData(topic, value)
def callbackSteal(self, topic, value): if value: self.buzzer.buzzerOn() self.alertSteal.turnOn() else: self.buzzer.buzzerOff() self.alertSteal.turnOff() setData(topic, value) print(self.value())
def callback(self, topic, value): state = getData(topic) if value != state and isinstance(value, bool): if value: self.turnOn() setData(topic, value) else: self.turnOff() setData(topic, value) print('valor de ',self.value())
def WriteValue(self, value, options): self.value = value string = "" i = 1 for byte in self.value: if isinstance(byte, dbus.Byte): string += "%i" % int(byte) if (divmod(i, 3)[1] != 0): string += "," else: if i < (len(self.value)): string += ":" i += 1 data.setData("rgb_flash_sequence", string)
def update(): patch = json.loads(request.data) setData(updateData(patch, getData())) return json.dumps(getData())
def WriteValue(self, value, options): self.value = value data.setData("rgb_fade_delay", int(self.value[0]))
def WriteValue(self, value, options): self.value = value data.setData("rgb_mode", int(self.value[0]))
def WriteValue(self, value, options): self.value = value string = "%i:%i,%i:%i" % (int(self.value[0]), int( self.value[1]), int(self.value[2]), int(self.value[3])) data.setData("autosleep_time", string)
def WriteValue(self, value, options): self.value = value data.setData("autosleep", int(self.value[0]))
def WriteValue(self, value, options): self.value = value data.setData("pota_quote_show", int(self.value[0]))
domain = "https://api.solardata2.tk" url = domain + "/api/inverter/stats/add" print(url) while True: try: base_path = os.path.dirname(os.path.abspath( inspect.getfile(inspect.currentframe()))) + "/" print(base_path) restart.reboot() update(base_path) print(slave_ids) for slave_id in slave_ids: for i in registers.keys(): initmodbusandread(i) timesend = str(dt.readTime().strftime("%Y-%m-%d %H:%M:%S")) # timesend = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") print(timesend) # onoff() print(uid + "{0:0=2d}".format(slave_id)) data = setData(uid, slave_id, registers, timesend, vers) sdata = setCsvData(uid, slave_id, registers, timesend, vers) headers = {'Content-type': 'application/json'} senddata(file_name, url, sdata, headers, data, vers) time.sleep(10*20) except Exception as e: print(e) restart.reboot() time.sleep(10)