mirror of
https://github.com/esphome/esphome.git
synced 2024-12-26 07:24:54 +01:00
fix for address config in schedule text_sensors
This commit is contained in:
parent
33c9746ef7
commit
bfeeefb2b4
1 changed files with 12 additions and 3 deletions
|
@ -41,12 +41,21 @@ OptolinkTextSensor = optolink_ns.class_(
|
|||
|
||||
def check_address():
|
||||
def validator_(config):
|
||||
address_needed = config[CONF_MODE] in ["MAP", "RAW"]
|
||||
address_needed = config[CONF_MODE] in [
|
||||
"MAP",
|
||||
"RAW",
|
||||
"DAY_SCHEDULE",
|
||||
"DAY_SCHEDULE_SYNCHRONIZED",
|
||||
]
|
||||
address_defined = CONF_ADDRESS in config
|
||||
if address_needed and not address_defined:
|
||||
raise cv.Invalid(f"{CONF_ADDRESS} is required in mode MAP or RAW")
|
||||
raise cv.Invalid(
|
||||
f"{CONF_ADDRESS} is required in mode MAP, RAW, DAY_SCHEDULE or DAY_SCHEDULE_SYNCHRONIZED"
|
||||
)
|
||||
if not address_needed and address_defined:
|
||||
raise cv.Invalid(f"{CONF_ADDRESS} is only allowed in mode MAP or RAW")
|
||||
raise cv.Invalid(
|
||||
f"{CONF_ADDRESS} is only allowed in mode MAP, RAW, DAY_SCHEDULE or DAY_SCHEDULE_SYNCHRONIZED"
|
||||
)
|
||||
return config
|
||||
|
||||
return validator_
|
||||
|
|
Loading…
Reference in a new issue