Pyscript - new integration for easy and powerful Python scripting

Exception in <file.wiki.search_wikipedia> line 6: summary = task.executor(wikipedia.summary, kwargs=funcArgs) ^ TypeError: summary() got an unexpected keyword argument 'kwargs'

Thanks for your persistence. Still not working :frowning: I feel very confident that this will work if somehow we can get the variables passed.

Sorry it took me a bit longer, but I got it working!

@service(supports_response="optional")
def search_wikipedia(searchterm=None, return_response=True):
    """yaml
    name: Search Wikipedia
    description: hello_world service example using pyscript.
    fields:
        searchterm:
            description: What to search for?
            example: Madonna
            required: true
            selector:
                text:
    """
    funcArgs = {"sentences": 2, "auto_suggest": False}
    summary = task.executor(wikipedia.summary, searchterm, **funcArgs)
    response_variable = { "summary": summary }
    return response_variable

I am not fully sure why query cannot be in the **kwargs argument of task.executor honestly. But calling this service from Home Assistant returned a summary of Madonna for me.

1 Like

You are the champion of champions my friend! I cannot thank you enough. This opens so many possibilities for me and the users of my project. We will be able to extend this to other APIs for grabbing data.

If interested, check out the project wiki and/or Discord:

It’s still in beta but really close to release.

1 Like