def read_meter(device,dest_file,usb,erase=False): plg = Plug(device,usb) last_ts = 0 #open the destination file and read the last timestamp if(os.path.isfile(dest_file)): with open(dest_file) as f: reader = csv.reader(f) for row in reader: last_ts = row[0] #check the plug for new data data = plg.get_data(int(float(last_ts))) if(data==None): print("no new data available, exiting") else: #if we are on wifi, append the data to the file if(usb==False): with open(dest_file, 'a') as f: writer = csv.writer(f) writer.writerows(data) #if this is a USB data dump, don't append else: with open(dest_file,'w') as f: writer = csv.writer(f) writer.writerows(data) #erase if requested if(erase): plg.erase_data() print "\t erased data" print "All data retrieved, unplug smartee to reset"
def read_meter(device, dest_file, usb, erase=False): plg = Plug(device, usb) last_ts = 0 #open the destination file and read the last timestamp if (os.path.isfile(dest_file)): with open(dest_file) as f: reader = csv.reader(f) for row in reader: last_ts = row[0] #check the plug for new data data = plg.get_data(int(float(last_ts))) if (data == None): print("no new data available, exiting") else: #if we are on wifi, append the data to the file if (usb == False): with open(dest_file, 'a') as f: writer = csv.writer(f) writer.writerows(data) #if this is a USB data dump, don't append else: with open(dest_file, 'w') as f: writer = csv.writer(f) writer.writerows(data) #erase if requested if (erase): plg.erase_data() print "\t erased data" print "All data retrieved, unplug smartee to reset"
async def run(self, loop): _logger.info("----- CONNECTING TO FHEM -----") fhem_connection = self.connect_fhem() _logger.info("----- CONNECTING TO MEROSS -----") self._meross = await self.connect_meross() _logger.info("----- INITIALIZING DEVICES -----") devices = self._meross.find_devices() for dev in devices: if dev.type == "msg100": await self.init_device( GarageDoorOpener(dev, fhem_connection, _logger)) if dev.type == "mss310": await self.init_device(Plug(dev, fhem_connection, _logger)) _logger.info("----- START LISTEN TO FHEM -----") que = Queue() t = threading.Thread(target=self.start_listen_to_fhem, args=(que, loop)) t.daemon = True t.start() _logger.info("----- INITIALIZATION FINISHED -----") await self.__shutdown_event.wait() _logger.info("----- SHUTDOWN COMPLETE -----")
def addPlug(self, testName): p = Plug(testName) self.measurements.append(p) return p
def setUp(self): """ Provide the test enviroment """ self._plug = Plug(id_site=1, dados={"titulo":"test", "path":"/tmp", "hora":"", "schema":""}) self._plug._getImpresso = lambda x=self:self._test self._test = [ {'document': { 'docname': 'EVE2505P0005', 'id_content': 123456, 'Titulo':'Test one', 'Bigode':'bigode test', 'Autor':'Alexandre Gans', 'Titulo_galeria':'Titulo da galeria', 'Paragrafo':'Corpo da noticia blah blah blah', 'ordem':1, }, 'images':[ {'Imagem':'http://host/someimage.gif', 'Autor':'autor 1', 'Legenda':'legenda 1', 'destaque': True}, {'Imagem':'http://host/someimage2.gif', 'Autor':'autor 2', 'Legenda':'legenda 2', 'destaque': False}, ], 'videos':[ {'Video':'http://host/video.mp4', 'thumb':'', 'Titulo':'titulo video 1'}, {'Video':'http://host/video.mp4', 'thumb':'', 'Titulo':'titulo video 2'}, ], 'correlata':[181664, 181663,] }, {'document': { 'docname': 'EVE2505P0004', 'id_content': 123455, 'Titulo':'Title with non-ascii téste ação <b>test</b>& te4ste', 'Bigode':'bigode ação', 'Autor':'Alexandre Gáns', 'Titulo_galeria':'Título da galêria', 'Paragrafo':"""Corpô da notícia blah blah blah [FOTO1] teste <b>adfasdf <a href="htttp://"> teste ação &% sadf#$12 test? > test ´ test """, 'ordem':2, }, 'images':[ {'Imagem':'http://host/someimage.gif', 'Autor':'autôr 1', 'Legenda':'légenda 1', 'destaque': True}, {'Imagem':'http://host/someimage2.gif', 'Autor':'áutor 2', 'Legenda':'lêgenda 2', 'destaque': False}, ], 'videos':[ {'Video':'http://host/video.mp4', 'thumb':'', 'Titulo':'título video 1'}, {'Video':'http://host/video.mp4', 'thumb':'', 'Titulo':'títúlô video 2'}, ], 'correlata':[181665, 181666,] }, ]
def set_relay(device,value,usb): plg = Plug(device,usb) plg.set_relay(value)
def set_relay(device, value, usb): plg = Plug(device, usb) plg.set_relay(value)