mirror of
https://github.com/esphome/esphome.git
synced 2025-09-06 05:12:21 +01:00
@@ -566,6 +566,23 @@ def mac_address(value):
|
||||
return core.MACAddress(*parts_int)
|
||||
|
||||
|
||||
def bind_key(value):
|
||||
value = string_strict(value)
|
||||
parts = [value[i:i+2] for i in range(0, len(value), 2)]
|
||||
if len(parts) != 16:
|
||||
raise Invalid("Bind key must consist of 16 hexadecimal numbers")
|
||||
parts_int = []
|
||||
if any(len(part) != 2 for part in parts):
|
||||
raise Invalid("Bind key must be format XX")
|
||||
for part in parts:
|
||||
try:
|
||||
parts_int.append(int(part, 16))
|
||||
except ValueError:
|
||||
raise Invalid("Bind key must be hex values from 00 to FF")
|
||||
|
||||
return ''.join(f'{part:02X}' for part in parts_int)
|
||||
|
||||
|
||||
def uuid(value):
|
||||
return Coerce(uuid_.UUID)(value)
|
||||
|
||||
|
Reference in New Issue
Block a user