Update sensor.py (#44350)

BME280 sensor has a resolution of 0.01 degree (20 bits) so temperature values should be rounded to 2 decimal places
pull/44364/head
Heisenberg 2020-12-18 19:29:16 +00:00 committed by GitHub
parent ae596c7dff
commit ea578f5767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -169,9 +169,9 @@ class BME280Sensor(Entity):
await self.hass.async_add_executor_job(self.bme280_client.update)
if self.bme280_client.sensor.sample_ok:
if self.type == SENSOR_TEMP:
temperature = round(self.bme280_client.sensor.temperature, 1)
temperature = round(self.bme280_client.sensor.temperature, 2)
if self.temp_unit == TEMP_FAHRENHEIT:
temperature = round(celsius_to_fahrenheit(temperature), 1)
temperature = round(celsius_to_fahrenheit(temperature), 2)
self._state = temperature
elif self.type == SENSOR_HUMID:
self._state = round(self.bme280_client.sensor.humidity, 1)