Allow rx_only mode of sds011 component (#534)

fixes the following error if rx_only was defined and update_interval
was not present:

Failed config

sensor.sds011: [source sds011.yaml:62]

  update_interval has no effect in rx_only mode. Please remove it.
This commit is contained in:
puuu 2019-05-10 20:48:50 +09:00 committed by Otto Winter
parent bb1937ab88
commit b0e6b48c50

View file

@ -33,7 +33,7 @@ CONFIG_SCHEMA = cv.All(cv.Schema({
sensor.sensor_schema(UNIT_MICROGRAMS_PER_CUBIC_METER, ICON_CHEMICAL_WEAPON, 1),
cv.Optional(CONF_RX_ONLY, default=False): cv.boolean,
cv.Optional(CONF_UPDATE_INTERVAL, default='0min'): cv.positive_time_period_minutes,
cv.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_minutes,
}).extend(cv.COMPONENT_SCHEMA).extend(uart.UART_DEVICE_SCHEMA), validate_sds011_rx_mode)
@ -42,6 +42,7 @@ def to_code(config):
yield cg.register_component(var, config)
yield uart.register_uart_device(var, config)
if CONF_UPDATE_INTERVAL in config:
cg.add(var.set_update_interval_min(config[CONF_UPDATE_INTERVAL]))
cg.add(var.set_rx_mode_only(config[CONF_RX_ONLY]))