mirror of https://github.com/esphome/esphome.git
Optional section at start of obis code
This commit is contained in:
parent
7a91ca9809
commit
c2df7a9d55
|
@ -32,7 +32,7 @@ async def to_code(config):
|
||||||
|
|
||||||
def obis_code(value):
|
def obis_code(value):
|
||||||
value = cv.string(value)
|
value = cv.string(value)
|
||||||
match = re.match(r"^\d{1,3}-\d{1,3}:\d{1,3}\.\d{1,3}\.\d{1,3}$", value)
|
match = re.match(r"^(?:\d{1,3}-\d{1,3}:)?\d{1,3}\.\d{1,3}\.\d{1,3}$", value)
|
||||||
if match is None:
|
if match is None:
|
||||||
raise cv.Invalid(f"{value} is not a valid OBIS code")
|
raise cv.Invalid(f"{value} is not a valid OBIS code")
|
||||||
return value
|
return value
|
||||||
|
|
Loading…
Reference in New Issue