mirror of
https://github.com/esphome/esphome.git
synced 2025-02-18 01:03:12 +01:00
support empty schemas and one platform components (#4999)
This commit is contained in:
parent
8a1c49a4ae
commit
2a2d20a7fc
1 changed files with 7 additions and 1 deletions
|
@ -461,8 +461,10 @@ def merge(source, destination):
|
||||||
|
|
||||||
def is_platform_schema(schema_name):
|
def is_platform_schema(schema_name):
|
||||||
# added mostly because of schema_name == "microphone.MICROPHONE_SCHEMA"
|
# added mostly because of schema_name == "microphone.MICROPHONE_SCHEMA"
|
||||||
|
# and "alarm_control_panel"
|
||||||
# which is shrunk because there is only one component of the schema (i2s_audio)
|
# which is shrunk because there is only one component of the schema (i2s_audio)
|
||||||
return schema_name == "microphone.MICROPHONE_SCHEMA"
|
component = schema_name.split(".")[0]
|
||||||
|
return component in components and components[component].is_platform_component
|
||||||
|
|
||||||
|
|
||||||
def shrink():
|
def shrink():
|
||||||
|
@ -530,6 +532,10 @@ def shrink():
|
||||||
elif not key_s:
|
elif not key_s:
|
||||||
for target in paths:
|
for target in paths:
|
||||||
target_s = get_arr_path_schema(target)
|
target_s = get_arr_path_schema(target)
|
||||||
|
if S_SCHEMA not in target_s:
|
||||||
|
# an empty schema like speaker.SPEAKER_SCHEMA
|
||||||
|
target_s[S_EXTENDS].remove(x)
|
||||||
|
continue
|
||||||
assert target_s[S_SCHEMA][S_EXTENDS] == [x]
|
assert target_s[S_SCHEMA][S_EXTENDS] == [x]
|
||||||
target_s.pop(S_SCHEMA)
|
target_s.pop(S_SCHEMA)
|
||||||
target_s.pop(S_TYPE) # undefined
|
target_s.pop(S_TYPE) # undefined
|
||||||
|
|
Loading…
Add table
Reference in a new issue