1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 05:12:21 +01:00

Add native API user-defined services (#453)

This commit is contained in:
Otto Winter
2019-02-26 19:38:28 +01:00
committed by GitHub
parent 3b00cfd6c4
commit 311e837196
3 changed files with 47 additions and 5 deletions

View File

@@ -162,7 +162,7 @@ def int_(value):
hex_int = vol.Coerce(hex_int_)
def variable_id_str_(value):
def validate_id_name(value):
value = string(value)
if not value:
raise vol.Invalid("ID must not be empty")
@@ -185,7 +185,7 @@ def use_variable_id(type):
if value is None:
return core.ID(None, is_declaration=False, type=type)
return core.ID(variable_id_str_(value), is_declaration=False, type=type)
return core.ID(validate_id_name(value), is_declaration=False, type=type)
return validator
@@ -195,7 +195,7 @@ def declare_variable_id(type):
if value is None:
return core.ID(None, is_declaration=True, type=type)
return core.ID(variable_id_str_(value), is_declaration=True, type=type)
return core.ID(validate_id_name(value), is_declaration=True, type=type)
return validator