[FIX] New tentative to retrieve the fields
This commit is contained in:
parent
e17787fa0f
commit
2120685cdf
@ -81,26 +81,17 @@ 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")
|
# Get script name from entity_id
|
||||||
script_name = entity_id.split(".", 1)[1]
|
script_name = entity_id.split(".", 1)[1]
|
||||||
|
|
||||||
# Get service definition from services registry to access fields
|
# Get service description which includes field definitions
|
||||||
service_data = hass.services.async_services().get("script", {}).get(script_name)
|
|
||||||
|
|
||||||
fields = {}
|
fields = {}
|
||||||
if service_data and hasattr(service_data, "fields"):
|
try:
|
||||||
# Convert service fields to our format
|
service_desc = hass.services.async_describe_service("script", script_name)
|
||||||
fields = {
|
if service_desc and "fields" in service_desc:
|
||||||
field_name: {
|
fields = service_desc["fields"]
|
||||||
"name": field_info.get("name", field_name),
|
except Exception as e:
|
||||||
"description": field_info.get("description", ""),
|
_LOGGER.debug(f"Could not get service description for {entity_id}: {e}")
|
||||||
"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(
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user