From b65cc21212042b5d814123612f9669a58bcf826d Mon Sep 17 00:00:00 2001 From: Stephen Tierney Date: Sat, 6 Feb 2021 20:32:17 +1100 Subject: [PATCH] Add test and bugfix --- esphome/components/ltr390/sensor.py | 28 ++++++++++++++-------------- tests/test1.yaml | 9 +++++++++ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/esphome/components/ltr390/sensor.py b/esphome/components/ltr390/sensor.py index 41ffdf3197..aef3339364 100644 --- a/esphome/components/ltr390/sensor.py +++ b/esphome/components/ltr390/sensor.py @@ -18,23 +18,23 @@ CONF_WFAC = 'wfac' UNIT_COUNTS = '#' UNIT_UVI = 'UVI' -ltr390_gain_t = ltr390_ns.enum('ltr390_gain_t') +LTR390GAIN = ltr390_ns.enum('LTR390GAIN') GAIN_OPTIONS = { - "X1": ltr390_gain_t.LTR390_GAIN_1, - "X3": ltr390_gain_t.LTR390_GAIN_3, - "X6": ltr390_gain_t.LTR390_GAIN_6, - "X9": ltr390_gain_t.LTR390_GAIN_9, - "X18": ltr390_gain_t.LTR390_GAIN_18, + "X1": LTR390GAIN.LTR390_GAIN_1, + "X3": LTR390GAIN.LTR390_GAIN_3, + "X6": LTR390GAIN.LTR390_GAIN_6, + "X9": LTR390GAIN.LTR390_GAIN_9, + "X18": LTR390GAIN.LTR390_GAIN_18, } -ltr390_resolution_t = ltr390_ns.enum('ltr390_resolution_t') +LTR390RESOLUTION = ltr390_ns.enum('LTR390RESOLUTION') RES_OPTIONS = { - 20: ltr390_resolution_t.LTR390_RESOLUTION_20BIT, - 19: ltr390_resolution_t.LTR390_RESOLUTION_19BIT, - 18: ltr390_resolution_t.LTR390_RESOLUTION_18BIT, - 17: ltr390_resolution_t.LTR390_RESOLUTION_17BIT, - 16: ltr390_resolution_t.LTR390_RESOLUTION_16BIT, - 13: ltr390_resolution_t.LTR390_RESOLUTION_13BIT, + 20: LTR390RESOLUTION.LTR390_RESOLUTION_20BIT, + 19: LTR390RESOLUTION.LTR390_RESOLUTION_19BIT, + 18: LTR390RESOLUTION.LTR390_RESOLUTION_18BIT, + 17: LTR390RESOLUTION.LTR390_RESOLUTION_17BIT, + 16: LTR390RESOLUTION.LTR390_RESOLUTION_16BIT, + 13: LTR390RESOLUTION.LTR390_RESOLUTION_13BIT, } CONFIG_SCHEMA = cv.Schema({ @@ -47,7 +47,7 @@ CONFIG_SCHEMA = cv.Schema({ cv.Optional(CONF_UV): sensor.sensor_schema(UNIT_COUNTS, ICON_BRIGHTNESS_5, 1), cv.Optional(CONF_GAIN, default="X3"): cv.enum(GAIN_OPTIONS), - cv.Optional(CONF_RESOLUTION, default="18"): cv.enum(RES_OPTIONS), + cv.Optional(CONF_RESOLUTION, default=18): cv.enum(RES_OPTIONS), cv.Optional(CONF_WFAC, default=1.0): cv.float_range(min=1.0), }).extend(cv.polling_component_schema('60s')).extend(i2c.i2c_device_schema(0x53)) diff --git a/tests/test1.yaml b/tests/test1.yaml index f5c3ab9b57..5abc74250b 100644 --- a/tests/test1.yaml +++ b/tests/test1.yaml @@ -565,6 +565,15 @@ sensor: humidity: name: 'Living Room Humidity 6' update_interval: 15s + - platform: ltr390 + uv: + name: "LTR390 UV" + uvi: + name: "LTR390 UVI" + light: + name: "LTR390 Light" + als: + name: "LTR390 ALS" - platform: max6675 name: 'Living Room Temperature' cs_pin: GPIO23