Log when BME sensor is not found during setup & when spawning sensor background task
This commit is contained in:
		| @@ -22,7 +22,10 @@ if isItInArgv('-d') or isItInArgv('--daemon'): | |||||||
|     brewCamera.spawnBackgroundCapture() |     brewCamera.spawnBackgroundCapture() | ||||||
|  |  | ||||||
|     for sensor in sensors: |     for sensor in sensors: | ||||||
|         sensor.spawnBackgroundSensorLog() |         try: | ||||||
|  |             sensor.spawnBackgroundSensorLog() | ||||||
|  |         except Error as error: | ||||||
|  |             print('Error while spawning sensor background task:', error) | ||||||
|  |  | ||||||
| def sensorTemp(location): | def sensorTemp(location): | ||||||
|     sensor = BrewSensor.getSensorByItsLocation(sensors, location) |     sensor = BrewSensor.getSensorByItsLocation(sensors, location) | ||||||
|   | |||||||
| @@ -79,20 +79,27 @@ class BME680Sensor(BrewSensor): | |||||||
|     def __init__(self, location, interval): |     def __init__(self, location, interval): | ||||||
|         super().__init__(location, interval) |         super().__init__(location, interval) | ||||||
|  |  | ||||||
|         self.sensor = bme680.BME680() |  | ||||||
|         self.sensor.set_humidity_oversample(bme680.OS_2X) |  | ||||||
|         self.setupSensors() |         self.setupSensors() | ||||||
|         self.lastSensorRead = time.time() |         self.lastSensorRead = time.time() | ||||||
|  |  | ||||||
|     def setupSensors(self): |     def setupSensors(self): | ||||||
|         self.sensor.set_pressure_oversample(bme680.OS_4X) |         try: | ||||||
|         self.sensor.set_temperature_oversample(bme680.OS_8X) |             self.sensor = bme680.BME680() | ||||||
|         self.sensor.set_filter(bme680.FILTER_SIZE_3) |             self.sensor.set_humidity_oversample(bme680.OS_2X) | ||||||
|  |             self.sensor.set_pressure_oversample(bme680.OS_4X) | ||||||
|  |             self.sensor.set_temperature_oversample(bme680.OS_8X) | ||||||
|  |             self.sensor.set_filter(bme680.FILTER_SIZE_3) | ||||||
|  |  | ||||||
|         self.sensor.set_gas_status(bme680.ENABLE_GAS_MEAS) |             self.sensor.set_gas_status(bme680.ENABLE_GAS_MEAS) | ||||||
|         self.sensor.set_gas_heater_temperature(320) |             self.sensor.set_gas_heater_temperature(320) | ||||||
|         self.sensor.set_gas_heater_duration(150) |             self.sensor.set_gas_heater_duration(150) | ||||||
|         self.sensor.select_gas_heater_profile(0) |             self.sensor.select_gas_heater_profile(0) | ||||||
|  |         except RuntimeError as error: | ||||||
|  |             logger.error('Sensor not found!', es={ | ||||||
|  |                 'location': self.location, | ||||||
|  |                 'error': str(error), | ||||||
|  |                 'exception': error.__class__.__name__ | ||||||
|  |             }) | ||||||
|  |  | ||||||
|     def read(self): |     def read(self): | ||||||
|         self.lastSensorRead = time.time() |         self.lastSensorRead = time.time() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user