mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 07:08:20 +00:00
Refactore ppd42x.py
This commit is contained in:
parent
4eb6a7d4cf
commit
2658e79e6c
@ -54,16 +54,16 @@ PLATFORM_SCHEMA = cv.nameable(sensor.PLATFORM_SCHEMA.extend({
|
|||||||
def to_code(config):
|
def to_code(config):
|
||||||
rhs = App.make_ppd42x(PPD42X_TYPES[config[CONF_TYPE]])
|
rhs = App.make_ppd42x(PPD42X_TYPES[config[CONF_TYPE]])
|
||||||
ppd = Pvariable(config[CONF_ID], rhs)
|
ppd = Pvariable(config[CONF_ID], rhs)
|
||||||
|
if CONF_PM_2_5 in config:
|
||||||
|
conf_02_5 = config[CONF_PM_2_5]
|
||||||
|
for pm_02_5 in get_variable(config[[CONF_PM_2_5][CONF_PIN]]):
|
||||||
|
yield
|
||||||
|
sensor.register_sensor(ppd.make_pm_02_5_sensor(conf_02_5[CONF_NAME]), pm_02_5)
|
||||||
if CONF_PM_10_0 in config:
|
if CONF_PM_10_0 in config:
|
||||||
conf_10_0 = config[CONF_PM_10_0]
|
conf_10_0 = config[CONF_PM_10_0]
|
||||||
for pm_10_0 in get_variable(conf_10_0[CONF_PIN]):
|
for pm_10_0 in get_variable(conf_10_0[CONF_PIN]):
|
||||||
yield
|
yield
|
||||||
sensor.register_sensor(ppd.make_pm_10_0_sensor(conf_10_0[CONF_NAME]), pm_10_0)
|
sensor.register_sensor(ppd.make_pm_10_0_sensor(conf_10_0[CONF_NAME]), pm_10_0)
|
||||||
if CONF_PM_2_5 in config:
|
|
||||||
conf_02_5 = config[CONF_PM_2_5]
|
|
||||||
for pm_02_5 in get_variable(conf_02_5[CONF_PIN]):
|
|
||||||
yield
|
|
||||||
sensor.register_sensor(ppd.make_pm_02_5_sensor(conf_02_5[CONF_NAME]), pm_02_5)
|
|
||||||
setup_component(ppd, config)
|
setup_component(ppd, config)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user