[pm1006] Fix "never" update interval detection (#12529)
This commit is contained in:
committed by
Jonathan Swoboda
parent
7e08092012
commit
195b1c6323
@@ -7,10 +7,10 @@ from esphome.const import (
|
|||||||
CONF_UPDATE_INTERVAL,
|
CONF_UPDATE_INTERVAL,
|
||||||
DEVICE_CLASS_PM25,
|
DEVICE_CLASS_PM25,
|
||||||
ICON_BLUR,
|
ICON_BLUR,
|
||||||
|
SCHEDULER_DONT_RUN,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
UNIT_MICROGRAMS_PER_CUBIC_METER,
|
UNIT_MICROGRAMS_PER_CUBIC_METER,
|
||||||
)
|
)
|
||||||
from esphome.core import TimePeriodMilliseconds
|
|
||||||
|
|
||||||
CODEOWNERS = ["@habbie"]
|
CODEOWNERS = ["@habbie"]
|
||||||
DEPENDENCIES = ["uart"]
|
DEPENDENCIES = ["uart"]
|
||||||
@@ -41,16 +41,12 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
|
|
||||||
|
|
||||||
def validate_interval_uart(config):
|
def validate_interval_uart(config):
|
||||||
require_tx = False
|
|
||||||
|
|
||||||
interval = config.get(CONF_UPDATE_INTERVAL)
|
interval = config.get(CONF_UPDATE_INTERVAL)
|
||||||
|
|
||||||
if isinstance(interval, TimePeriodMilliseconds):
|
|
||||||
# 'never' is encoded as a very large int, not as a TimePeriodMilliseconds objects
|
|
||||||
require_tx = True
|
|
||||||
|
|
||||||
uart.final_validate_device_schema(
|
uart.final_validate_device_schema(
|
||||||
"pm1006", baud_rate=9600, require_rx=True, require_tx=require_tx
|
"pm1006",
|
||||||
|
baud_rate=9600,
|
||||||
|
require_rx=True,
|
||||||
|
require_tx=interval.total_milliseconds != SCHEDULER_DONT_RUN,
|
||||||
)(config)
|
)(config)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user