def getNDIRCO2Obsv(self, test=False): '''CO2 from the canopy (NDIR sensor) Args: self: test: Returns: None: Raises: None ''' status_qualifier = 'Success' co2 = 0 temp = 0 rh = 0 try: from NDIR import Sensor sensor = Sensor() sensor.begin(test) co2 = sensor.getCO2(test) if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Canopy', 'Air', 'CO2', "{:3.1f}".format(co2), 'ppm', 'NDIR', status_qualifier,'']) self._logger.debug("{}, {}, {:10.1f}".format("NDIR Canopy CO2", status_qualifier, co2)) except Exception as e: status_qualifier = 'Failure' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Canopy', 'Air', 'CO2', '', 'ppm', 'NDIR', status_qualifier,str(e)]) self._logger.error("{}, {}".format("NDIR Canopy CO2", e))
def getAirTopTempObsv(self, test=False): '''One-Wire thermometer assigned to top of box Args: self: test: Returns: None: Raises: None ''' try: temp = getTempC(topTemp) status_qualifier = 'Success' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Top', 'Air', 'Temperature', "{:10.1f}".format(temp), 'Centigrade', 'DS18B20_3', status_qualifier,'']) self._logger.debug("{}, {}, {:10.1f}".format("Top Air Temp", status_qualifier, temp)) except Exception as e: status_qualifier = 'Failure' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Top', 'Air', 'Temperature', '', 'Centigrade', 'DS18B20_3', status_qualifier, str(e)]) self._logger.error("{}, {}".format("Top Air Temp", e))
def getLightCanopyLUXObsv(self, test=False): '''LUX light reading from the canopy Args: self: test: Returns: None: Raises: None ''' lx = TSL2561() try: lux = lx.getLux() status_qualifier = 'Success' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Canopy', 'Light', 'LUX', "{:3.1f}".format(lux), 'lux', 'TSL2561', status_qualifier,'']) self._logger.debug("{}, {}, {:10.1f}".format("Canopy LUX", status_qualifier, lux)) except Exception as e: status_qualifier = 'Failure' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Canopy', 'Light', 'LUX', '', 'lux', 'TSL2561', status_qualifier,str(e)]) self._logger.error("{}, {}".format("Canopy LUX", e))
def getSecondCO2(self, test=False): '''CO2 from the canopy (CCS811 sensor) Args: self: test: Returns: None: Raises: None ''' try: sensor = CCS811(SLAVE) co2 = sensor.get_co2() status_qualifier = 'Success' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Canopy', 'Air', 'CO2', "{:3.1f}".format(co2), 'ppm', 'CCS811', status_qualifier,'']) self._logger.debug("{}, {}, {:10.1f}".format("Alt CO2", status_qualifier, co2)) except Exception as e: status_qualifier = 'Failure' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Canopy', 'Air', 'CO2','', 'ppm', 'CCS811', status_qualifier,str(e)]) self._logger.error("{}, {}".format("Alt CO2", e) )
def getNutrientReservoirECObsv(self, test=False): '''Electrical conductivity of the reservoir Often used to control the filler system Args: self: test: Returns: None: Raises: None ''' try: s = EC() ec = s.getEC() status_qualifier = 'Success' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Reservoir', 'Nutrient', 'EC', "{:3.1f}".format(ec), 'EC', 'EC', status_qualifier,'']) self._logger.debug("{}, {}, {:10.1f}".format("Reservoir EC", status_qualifier, ec)) except Exception as e: status_qualifier = 'Failure' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Reservoir', 'Nutrient', 'EC', '', 'EC', 'EC', status_qualifier,str(e)]) self._logger.error("{}, {}".format("Reservoir Depth", e))
def log_state(self, value, test=False): """ Create Environment Observation """ status_qualifier = 'Success' if test: status_qualifier = 'Test' saveList([ 'State_Change', '', 'Top', 'Lights', 'State', value, 'Lights', 'state', status_qualifier, '' ])
def log_state(self, value, test=False): """Send state change to database Args: value: state change test: flag for testing Returns: None Raises: None """ status_qualifier = 'Success' if test: status_qualifier = 'Test' saveList(['State_Change', '', 'Side', 'Fan', 'State', value, 'state', 'Fan', status_qualifier, ''])
def logState(self, value, status, test=False): if test: status = 'Test' txt = { 'EC': value, 'full_level': self.res['full'], 'empty_level': self.res['empty'], 'status': 'Full' } if test: status_qualifier = 'Test' # record_env(self._activity_type, 'Nutrient', 'Reservoir', 'Volume', 'value', 'EC', status) saveList([ 'State_Change', '', 'Nutrient', 'Reservoir', 'Volume', value, 'EC', 'Solenoid', status_qualifier, '' ])
def log_sensors(test=False): sensor = TempSensor() try: temp = sensor.check_temperature() status = 'Success' if test: status = 'Test' saveList([ 'Environment_Observation', '', 'Top', 'Air', 'Temperature', "{:10.1f}".format(temp), 'Farenheight', sensor.SENSOR_TYPE, status, '' ]) except Exception as e: status = 'Failure' if test: status = 'Test' saveList([ 'Environment_Observation', '', 'Top', 'Air', 'Temperature', '', 'Farenheight', sensor.SENSOR_TYPE, status, str(e) ]) try: humid = sensor.check_humidity() status = 'Success' if test: status = 'Test' saveList([ 'Environment_Observation', '', 'Top', 'Air', 'Humidity', "{:10.1f}".format(humid), 'Percent', sensor.SENSOR_TYPE, status, '' ]) except Exception as e: status = 'Failure' if test: status = 'Test' saveList([ 'Environment_Observation', '', 'Top', 'Air', 'Humidity', '', 'Percent', sensor.SENSOR_TYPE, status, str(e) ])
def log_sensors(test=False): si = SI7021() try: temp = si.get_tempC() status = 'Success' if test: status = 'Test' saveList([ 'Environment_Observation', '', 'Top', 'Air', 'Temperature', "{:10.1f}".format(temp), 'Farenheit', 'SI7021', status, '' ]) except Exception as e: status = 'Failure' if test: status = 'Test' saveList([ 'Environment_Observation', '', 'Top', 'Air', 'Temperature', '', 'Farenheit', 'SI7021', status, str(e) ]) try: humid = si.get_humidity() status = 'Success' if test: status = 'Test' saveList([ 'Environment_Observation', '', 'Top', 'Air', 'Humidity', "{:10.1f}".format(humid), 'Percent', 'SI7021', status, '' ]) except Exception as e: status = 'Failure' if test: status = 'Test' saveList([ 'Environment_Observation', '', 'Top', 'Air', 'Humidity', '', 'Percent', 'SI7021', status, str(e) ])
def getAirCanopyCO2Obsv(self, test=False): '''CO2 from the canopy (SCD30 Sensiron sensor) Args: self: test: Returns: None: Raises: None ''' status_qualifier = 'Success' co2 = 0 temp = 0 rh = 0 try: sensor = SCD30() sensor.start_periodic_measurement(test) co2, temp, rh = sensor.get_data(test) if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Canopy', 'Air', 'CO2', "{:3.1f}".format(co2), 'ppm', 'SCD30', status_qualifier,'']) self._logger.debug("{}, {}, {:10.1f}".format("Canopy CO2", status_qualifier, co2)) saveList([self._activity_type, '', 'Canopy', 'Air', 'Temperature', "{:3.1f}".format(temp), 'ppm', 'SCD30', status_qualifier,'']) self._logger.debug("{}, {}, {:10.1f}".format("Canopy Temperature", status_qualifier, temp)) saveList([self._activity_type, '', 'Canopy', 'Air', 'Humidity', "{:3.1f}".format(rh), 'ppm', 'SCD30', status_qualifier,'']) self._logger.debug("{}, {}, {:10.1f}".format("Canopy Humidity", status_qualifier, rh)) except Exception as e: status_qualifier = 'Failure' if test: status_qualifier = 'Test' saveList([self._activity_type, '', 'Canopy', 'Air', 'CO2', '', 'ppm', 'SCD30', status_qualifier,str(e)]) self._logger.error("{}, {}".format("Canopy CO2", e)) saveList([self._activity_type, '', 'Canopy', 'Air', 'Temperature', '', 'c', 'SCD30', status_qualifier,str(e)]) self._logger.error("{}, {}".format("Canopy CO2", e)) saveList([self._activity_type, '', 'Canopy', 'Air', 'Humidity', '', 'percent', 'SCD30', status_qualifier,str(e)]) self._logger.error("{}, {}".format("Canopy Humidity", e))
def logState(self, value, test=False): status_qualifier='Success' if test: status_qualifier='Test' saveList(['State_Change', '', 'Pump', 'Reservoir', 'State', value, 'state', 'Solenoid', status_qualifier, ''])