Ejemplo n.º 1
0
	def send_plug_measurement(self, data, message_filter):

		# check to see if the data is worthy of storing!
		# in order to scape storing Null values, when Zigbee
		# is shut down and send just POW=OFF in case of load overload
		if utilities.check_plug_measurement(data):
			_logger.debug('#debug:sending-plug=measurement-' + message_filter)
			self.send(message_filter+'load', data['load'])
			self.send(message_filter+'work', data['work'])
			self.send(message_filter+'power', data['pow'])
			self.send(message_filter+'frequency', data['freq'])
			self.send(message_filter+'vrms', data['vrms'])
			self.send(message_filter+'irms', data['irms'])
		else:
			# TODO send an email?
			_logger.error("#error-the-zigbee-device-has-been-turned-off-%s " % data)
Ejemplo n.º 2
0
    def send_plug_measurement(self, data, message_filter):

        # check to see if the data is worthy of storing!
        # in order to scape storing Null values, when Zigbee
        # is shut down and send just POW=OFF in case of load overload
        if utilities.check_plug_measurement(data):
            _logger.debug('#debug:sending-plug=measurement-' + message_filter)
            self.send(message_filter + 'load', data['load'])
            self.send(message_filter + 'work', data['work'])
            self.send(message_filter + 'power', data['pow'])
            self.send(message_filter + 'frequency', data['freq'])
            self.send(message_filter + 'vrms', data['vrms'])
            self.send(message_filter + 'irms', data['irms'])
        else:
            # TODO send an email?
            _logger.error("#error-the-zigbee-device-has-been-turned-off-%s " %
                          data)
Ejemplo n.º 3
0
 def insert(self,data):
     """
     insert the data into related table of the Postgress Database
     :param data: dictionary representing a measurement of a device
     :return:
     """
     ty = data['type']
     if ty == 'power_measurement':
         _logger.debug("#debug:inserting-power-measurement")
         self.insert_power_measurement(data)
     elif ty == 'plug_measurement':
         # check if plug-measurement is worthy of storing
         if utilities.check_plug_measurement(data):
             _logger.debug("#debug:inserting-plug-measurement")
             self.insert_plug_measurement(data)
         else:
             _logger.error("#error:zigbee-device-has-been-turned-off-%s" % data)
             # TODO do something! send an email?
     elif ty == 'temp_hum_measurement':
         _logger.debug("#debug:inserting-temp-hum-measurement")
         self.insert_temp_hum_measurement(data)
     else:
         _logger.warn("#warn:unknown-data")
Ejemplo n.º 4
0
 def insert(self, data):
     """
     insert the data into related table of the Postgress Database
     :param data: dictionary representing a measurement of a device
     :return:
     """
     ty = data['type']
     if ty == 'power_measurement':
         _logger.debug("#debug:inserting-power-measurement")
         self.insert_power_measurement(data)
     elif ty == 'plug_measurement':
         # check if plug-measurement is worthy of storing
         if utilities.check_plug_measurement(data):
             _logger.debug("#debug:inserting-plug-measurement")
             self.insert_plug_measurement(data)
         else:
             _logger.error("#error:zigbee-device-has-been-turned-off-%s" %
                           data)
             # TODO do something! send an email?
     elif ty == 'temp_hum_measurement':
         _logger.debug("#debug:inserting-temp-hum-measurement")
         self.insert_temp_hum_measurement(data)
     else:
         _logger.warn("#warn:unknown-data")