mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 15:18:16 +00:00
Refactore ppd42x.py
This commit is contained in:
parent
026bd039f1
commit
eed8d27f19
@ -52,21 +52,17 @@ PLATFORM_SCHEMA = vol.nameable(sensor.PLATFORM_SCHEMA.extend({
|
|||||||
def to_code(config):
|
def to_code(config):
|
||||||
rhs = App.make_ppd42x(config[CONF_NAME], PPD42X_TYPES[config[CONF_TYPE]])
|
rhs = App.make_ppd42x(config[CONF_NAME], PPD42X_TYPES[config[CONF_TYPE]])
|
||||||
pms = Pvariable(config[CONF_ID], rhs)
|
pms = Pvariable(config[CONF_ID], rhs)
|
||||||
|
|
||||||
if CONF_PM_2_5 in config:
|
if CONF_PM_2_5 in config:
|
||||||
conf = config[CONF_PM_2_5]
|
conf = config[CONF_PM_2_5]
|
||||||
for pm_02_5 in get_variable(conf[CONF_PIN]):
|
for pm_02_5 in get_variable(conf[CONF_PIN]):
|
||||||
yield
|
yield
|
||||||
sensor.register_sensor(pms.make_pm_2_5_sensor(conf[CONF_NAME]), conf)
|
sensor.register_sensor(pms.make_pm_2_5_sensor(conf[CONF_NAME]), conf)
|
||||||
|
|
||||||
|
|
||||||
if CONF_PM_10_0 in config:
|
if CONF_PM_10_0 in config:
|
||||||
conf = config[CONF_PM_10_0]
|
conf = config[CONF_PM_10_0]
|
||||||
for pm_10_0 in get_variable(conf[CONF_PIN]):
|
for pm_10_0 in get_variable(conf[CONF_PIN]):
|
||||||
yield
|
yield
|
||||||
sensor.register_sensor(pms.make_pm_10_0_sensor(conf[CONF_NAME]), conf)
|
sensor.register_sensor(pms.make_pm_10_0_sensor(conf[CONF_NAME]), conf)
|
||||||
|
|
||||||
|
|
||||||
setup_component(pms, config)
|
setup_component(pms, config)
|
||||||
|
|
||||||
|
|
||||||
BUILD_FLAGS = '-DUSE_PPD42X'
|
BUILD_FLAGS = '-DUSE_PPD42X'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user