[FIX] Fields were not populated for scripts
This commit is contained in:
parent
76bd1582e7
commit
e17787fa0f
@ -81,6 +81,27 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
if not state:
|
if not state:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Get script name from entity_id (e.g., "script.my_script" -> "my_script")
|
||||||
|
script_name = entity_id.split(".", 1)[1]
|
||||||
|
|
||||||
|
# Get service definition from services registry to access fields
|
||||||
|
service_data = hass.services.async_services().get("script", {}).get(script_name)
|
||||||
|
|
||||||
|
fields = {}
|
||||||
|
if service_data and hasattr(service_data, "fields"):
|
||||||
|
# Convert service fields to our format
|
||||||
|
fields = {
|
||||||
|
field_name: {
|
||||||
|
"name": field_info.get("name", field_name),
|
||||||
|
"description": field_info.get("description", ""),
|
||||||
|
"required": field_info.get("required", False),
|
||||||
|
"example": field_info.get("example"),
|
||||||
|
"default": field_info.get("default"),
|
||||||
|
"selector": field_info.get("selector"),
|
||||||
|
}
|
||||||
|
for field_name, field_info in service_data.fields.items()
|
||||||
|
}
|
||||||
|
|
||||||
scripts.append(
|
scripts.append(
|
||||||
{
|
{
|
||||||
"entity_id": entity_id,
|
"entity_id": entity_id,
|
||||||
@ -88,7 +109,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
"friendly_name", entity_id
|
"friendly_name", entity_id
|
||||||
),
|
),
|
||||||
"description": state.attributes.get("description", ""),
|
"description": state.attributes.get("description", ""),
|
||||||
"fields": state.attributes.get("fields", {}),
|
"fields": fields,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user