Skip to content

Commit

Permalink
Adds ability to calibrate temperature for BME680 (home-assistant#19684)
Browse files Browse the repository at this point in the history
* Adds temperature calibration

* Add deps.  Lint fix
  • Loading branch information
ctborg authored and cgarwood committed Jan 2, 2019
1 parent bba9ef7 commit 688bdc6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion homeassistant/components/sensor/bme680.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from homeassistant.helpers.entity import Entity
from homeassistant.util.temperature import celsius_to_fahrenheit

REQUIREMENTS = ['bme680==1.0.4',
REQUIREMENTS = ['bme680==1.0.5',
'smbus-cffi==0.5.1']

_LOGGER = logging.getLogger(__name__)
Expand All @@ -36,6 +36,7 @@
CONF_AQ_BURN_IN_TIME = 'aq_burn_in_time'
CONF_AQ_HUM_BASELINE = 'aq_humidity_baseline'
CONF_AQ_HUM_WEIGHTING = 'aq_humidity_bias'
CONF_TEMP_OFFSET = 'temp_offset'


DEFAULT_NAME = 'BME680 Sensor'
Expand All @@ -50,6 +51,7 @@
DEFAULT_AQ_BURN_IN_TIME = 300 # 300 second burn in time for AQ gas measurement
DEFAULT_AQ_HUM_BASELINE = 40 # 40%, an optimal indoor humidity.
DEFAULT_AQ_HUM_WEIGHTING = 25 # 25% Weighting of humidity to gas in AQ score
DEFAULT_TEMP_OFFSET = 0 # No calibration out of the box.

SENSOR_TEMP = 'temperature'
SENSOR_HUMID = 'humidity'
Expand Down Expand Up @@ -93,6 +95,8 @@
vol.All(vol.Coerce(int), vol.Range(1, 100)),
vol.Optional(CONF_AQ_HUM_WEIGHTING, default=DEFAULT_AQ_HUM_WEIGHTING):
vol.All(vol.Coerce(int), vol.Range(1, 100)),
vol.Optional(CONF_TEMP_OFFSET, default=DEFAULT_TEMP_OFFSET):
vol.All(vol.Coerce(float), vol.Range(-100.0, 100.0)),
})


Expand Down Expand Up @@ -140,6 +144,9 @@ def _setup_bme680(config):
sensor.set_temperature_oversample(
os_lookup[config.get(CONF_OVERSAMPLING_TEMP)]
)
sensor.set_temp_offset(
os_lookup[config.get(CONF_TEMP_OFFSET)]
)
sensor.set_humidity_oversample(
os_lookup[config.get(CONF_OVERSAMPLING_HUM)]
)
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ blockchain==1.4.4
# bluepy==1.1.4

# homeassistant.components.sensor.bme680
# bme680==1.0.4
# bme680==1.0.5

# homeassistant.components.route53
# homeassistant.components.notify.aws_lambda
Expand Down

0 comments on commit 688bdc6

Please sign in to comment.