mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 00:48:19 +01:00
Deep sleep is only available on esp32 and esp8266 (#5507)
This commit is contained in:
parent
c65d78f568
commit
be7e167c63
1 changed files with 34 additions and 27 deletions
|
@ -14,6 +14,8 @@ from esphome.const import (
|
||||||
CONF_SLEEP_DURATION,
|
CONF_SLEEP_DURATION,
|
||||||
CONF_TIME_ID,
|
CONF_TIME_ID,
|
||||||
CONF_WAKEUP_PIN,
|
CONF_WAKEUP_PIN,
|
||||||
|
PLATFORM_ESP32,
|
||||||
|
PLATFORM_ESP8266,
|
||||||
)
|
)
|
||||||
|
|
||||||
from esphome.components.esp32 import get_esp32_variant
|
from esphome.components.esp32 import get_esp32_variant
|
||||||
|
@ -165,34 +167,39 @@ WAKEUP_CAUSES_SCHEMA = cv.Schema(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.All(
|
||||||
{
|
cv.Schema(
|
||||||
cv.GenerateID(): cv.declare_id(DeepSleepComponent),
|
{
|
||||||
cv.Optional(CONF_RUN_DURATION): cv.Any(
|
cv.GenerateID(): cv.declare_id(DeepSleepComponent),
|
||||||
cv.All(cv.only_on_esp32, WAKEUP_CAUSES_SCHEMA),
|
cv.Optional(CONF_RUN_DURATION): cv.Any(
|
||||||
cv.positive_time_period_milliseconds,
|
cv.All(cv.only_on_esp32, WAKEUP_CAUSES_SCHEMA),
|
||||||
),
|
cv.positive_time_period_milliseconds,
|
||||||
cv.Optional(CONF_SLEEP_DURATION): cv.positive_time_period_milliseconds,
|
|
||||||
cv.Optional(CONF_WAKEUP_PIN): cv.All(
|
|
||||||
cv.only_on_esp32, pins.internal_gpio_input_pin_schema, validate_pin_number
|
|
||||||
),
|
|
||||||
cv.Optional(CONF_WAKEUP_PIN_MODE): cv.All(
|
|
||||||
cv.only_on_esp32, cv.enum(WAKEUP_PIN_MODES), upper=True
|
|
||||||
),
|
|
||||||
cv.Optional(CONF_ESP32_EXT1_WAKEUP): cv.All(
|
|
||||||
cv.only_on_esp32,
|
|
||||||
cv.Schema(
|
|
||||||
{
|
|
||||||
cv.Required(CONF_PINS): cv.ensure_list(
|
|
||||||
pins.internal_gpio_input_pin_schema, validate_pin_number
|
|
||||||
),
|
|
||||||
cv.Required(CONF_MODE): cv.enum(EXT1_WAKEUP_MODES, upper=True),
|
|
||||||
}
|
|
||||||
),
|
),
|
||||||
),
|
cv.Optional(CONF_SLEEP_DURATION): cv.positive_time_period_milliseconds,
|
||||||
cv.Optional(CONF_TOUCH_WAKEUP): cv.All(cv.only_on_esp32, cv.boolean),
|
cv.Optional(CONF_WAKEUP_PIN): cv.All(
|
||||||
}
|
cv.only_on_esp32,
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
pins.internal_gpio_input_pin_schema,
|
||||||
|
validate_pin_number,
|
||||||
|
),
|
||||||
|
cv.Optional(CONF_WAKEUP_PIN_MODE): cv.All(
|
||||||
|
cv.only_on_esp32, cv.enum(WAKEUP_PIN_MODES), upper=True
|
||||||
|
),
|
||||||
|
cv.Optional(CONF_ESP32_EXT1_WAKEUP): cv.All(
|
||||||
|
cv.only_on_esp32,
|
||||||
|
cv.Schema(
|
||||||
|
{
|
||||||
|
cv.Required(CONF_PINS): cv.ensure_list(
|
||||||
|
pins.internal_gpio_input_pin_schema, validate_pin_number
|
||||||
|
),
|
||||||
|
cv.Required(CONF_MODE): cv.enum(EXT1_WAKEUP_MODES, upper=True),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
),
|
||||||
|
cv.Optional(CONF_TOUCH_WAKEUP): cv.All(cv.only_on_esp32, cv.boolean),
|
||||||
|
}
|
||||||
|
).extend(cv.COMPONENT_SCHEMA),
|
||||||
|
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266]),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
|
|
Loading…
Reference in a new issue