Exemplo n.º 1
0
 def run(self):
     logging.info("DHT module initialized")
     webservice_state_instances_add(self.get_class_name(), self.get_json_status)
     timecheck = time.time()
     while not self.stop_event.is_set():
         time.sleep(1)
         humidity_previous = self.humidity
         temperature_previous = self.temperature
         self.humidity, self.temperature = Adafruit_DHT.read_retry(self.sensor, self.pin)
         if humidity_previous > self.humidity:
             c1 = humidity_previous - self.humidity
         else:
             c1 = self.humidity - humidity_previous
         if temperature_previous > self.temperature:
             c2 = temperature_previous - self.temperature
         else:
             c2 = self.temperature - temperature_previous
         if c1 > 5 or c2 > 2:
             # values have changed, add to plot data
             open(SENSORDHT_PLOTDATA_PATH + os.sep + time.strftime("%d.%m.%y.plotdata"), "a").write(
                 datetime.datetime.now().strftime("%d.%m.%y %H:%M:%S")
                 + "\t%.02f\t%.02f\n" % (self.temperature, self.humidity)
             )
             logging.info(
                 "plotting data due to change, prev h:%s cur h: %s prev t:%s cur t: %s - c1:%s c2:%s"
                 % (humidity_previous, self.humidity, temperature_previous, self.temperature, c1, c2)
             )
         # after 15 tries/30 seconds, None, None
         if time.time() - timecheck > 60:
             timecheck = time.time()
             logging.debug(
                 "60 interval - temperature: " + str(self.temperature) + " Humidity: " + str(self.humidity)
             )
         time.sleep(1)
Exemplo n.º 2
0
 def run(self):
     logging.info('DHT module initialized')
     webservice_state_instances_add(self.get_class_name(),
                                    self.get_json_status)
     timecheck = time.time()
     while not self.stop_event.is_set():
         time.sleep(1)
         humidity_previous = self.humidity
         temperature_previous = self.temperature
         self.humidity, self.temperature = Adafruit_DHT.read_retry(
             self.sensor, self.pin)
         if humidity_previous != self.humidity or temperature_previous != self.temperature:
             # values have changed, add to plot data
             open(
                 SENSORDHT_PLOTDATA_PATH + os.sep +
                 time.strftime('%d.%m.%y.plotdata'), 'a').write(
                     datetime.datetime.now().strftime('%d.%m.%y %H:%M:%S') +
                     '\t%.02f\t%.02f\n' % (self.temperature, self.humidity))
         #after 15 tries/30 seconds, None, None
         if time.time() - timecheck > 60:
             timecheck = time.time()
             logging.debug('60 interval - temperature: ' +
                           str(self.temperature) + ' Humidity: ' +
                           str(self.humidity))
         time.sleep(1)
Exemplo n.º 3
0
 def pre_processqueue(self):
     logging.info('CEC module initialized')
     webservice_state_instances_add(self.get_class_name(), self.get_json_status)
     webservice_class_instances_add(self.get_class_name(), self)
     self.updatedevices()
     self.timecheck = time.time()
     super(HACec, self).pre_processqueue()
Exemplo n.º 4
0
 def pre_processqueue(self):
     logging.info('CEC module initialized')
     webservice_state_instances_add(self.get_class_name(),
                                    self.get_json_status)
     webservice_class_instances_add(self.get_class_name(), self)
     self.updatedevices()
     self.timecheck = time.time()
     super(HACec, self).pre_processqueue()
Exemplo n.º 5
0
 def pre_processqueue(self):
     webservicedecorator_globals_add(rgbm=self.rgbm)
     webservice_state_instances_add(self.__class__.__name__, self.rgbm.get_json_state)
     webservice_class_instances_add(self.get_class_name(), self) # might be redundant
     webservice_class_instances_add('ledmatrixaudio', self) # TODO: iterate over modules from parent and find + add those that inherit matrix
     webservice_class_instances_add('ledmatriximage', self)
     self.rgbm.to_splashscreen()
     self.timecheck = time.time()
     super(LEDMatrixCore, self).pre_processqueue()
Exemplo n.º 6
0
    def pre_processqueue(self):
        logging.info('Philips Hue module initialized')
        self.bridge = Bridge(self.bridgeip)
        webservice_state_instances_add(self.__class__.__name__, self.get_json_status)
        webservice_class_instances_add(self.get_class_name(), self)
        self.update_light_instances()
        self.timecheck = time.time()
        self.update_light_cache()
        self.cachetime = time.time()
        logging.info('PhilipsHue module ready')

        super(HAPhilipsHue, self).pre_processqueue()
Exemplo n.º 7
0
    def pre_processqueue(self):
        logging.info('Belkin Wemo module initialized')
        self.env.start()
        self.env.discover(10)
        webservice_state_instances_add(self.__class__.__name__, self.get_json_status)
        webservice_class_instances_add(self.get_class_name(), self)
        self.update_light_instances()
        self.timecheck = time.time()
        self.update_light_cache()
        self.cachetime = time.time()
        logging.info('Belkin Wemo module ready')

        super(HABelkinWemo, self).pre_processqueue()
Exemplo n.º 8
0
 def pre_processqueue(self):
     webservicedecorator_globals_add(rgbm=self.rgbm)
     webservice_state_instances_add(self.__class__.__name__,
                                    self.rgbm.get_json_state)
     webservice_class_instances_add(self.get_class_name(),
                                    self)  # might be redundant
     webservice_class_instances_add(
         'ledmatrixaudio', self
     )  # TODO: iterate over modules from parent and find + add those that inherit matrix
     webservice_class_instances_add('ledmatriximage', self)
     self.rgbm.to_splashscreen()
     self.timecheck = time.time()
     super(LEDMatrixCore, self).pre_processqueue()
Exemplo n.º 9
0
    def run(self):
        logging.info('DHT module initialized')
        webservice_state_instances_add(self.get_class_name(), self.get_json_status)
        timecheck = time.time()
        while not self.stop_event.is_set():
            time.sleep(1)
            humidity_previous = self.humidity
            temperature_previous = self.temperature
            self.humidity, self.temperature = Adafruit_DHT.read_retry(self.sensor, self.pin)
            if humidity_previous != self.humidity or temperature_previous != self.temperature:
                # values have changed, add to plot data
                open(SENSORDHT_PLOTDATA_PATH + os.sep + time.strftime('%d.%m.%y.plotdata'), 'a').write(datetime.datetime.now().strftime('%d.%m.%y %H:%M:%S')
 + '\t%.02f\t%.02f\n' %(self.temperature, self.humidity) )
            #after 15 tries/30 seconds, None, None
            if time.time() - timecheck > 60:
                timecheck = time.time()
                logging.debug('60 interval - temperature: ' + str(self.temperature) + ' Humidity: ' + str(self.humidity))
            time.sleep(1)
Exemplo n.º 10
0
 def pre_processqueue(self):
     logging.info('Serial IR module initialized: ' + self.Serial.readline() )
     webservice_state_instances_add(self.__class__.__name__, self.get_json_status)
     webservice_class_instances_add(self.get_class_name(), self)
     self.timecheck = time.time()
     super(HASerialIR, self).pre_processqueue()