Add and use light lux constant in entire code base (#40171)

This commit is contained in:
springstan 2020-09-23 20:48:01 +02:00 committed by GitHub
parent 6a7caad8dc
commit 6c8e0e20fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 71 additions and 46 deletions

View file

@ -7,7 +7,7 @@ import smbus # pylint: disable=import-error
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_NAME, DEVICE_CLASS_ILLUMINANCE
from homeassistant.const import CONF_NAME, DEVICE_CLASS_ILLUMINANCE, LIGHT_LUX
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
@ -37,7 +37,6 @@ OPERATION_MODES = {
ONE_TIME_HIGH_RES_MODE_2: (0x21, False), # 0.5lx resolution.
}
SENSOR_UNIT = "lx"
DEFAULT_NAME = "BH1750 Light Sensor"
DEFAULT_I2C_ADDRESS = "0x23"
DEFAULT_I2C_BUS = 1
@ -85,7 +84,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
_LOGGER.error("BH1750 sensor not detected at %s", i2c_address)
return False
dev = [BH1750Sensor(sensor, name, SENSOR_UNIT, config[CONF_MULTIPLIER])]
dev = [BH1750Sensor(sensor, name, LIGHT_LUX, config[CONF_MULTIPLIER])]
_LOGGER.info(
"Setup of BH1750 light sensor at %s in mode %s is complete",
i2c_address,