-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use service responses in pyscript? #494
Comments
Yes, pyscript needs an update to support service responses. It's actually not hard to implement, just adding a few returns to specific places does the trick. If I find time during the weekend I may create a pull request which adds support for service responses. In the mean time you can use the service API provided directly by home assistant. For this to work you need to enable "Access hass as a global variable?" in the settings. Then you can access the home assistant service API using the hass object. Here's an example of getting a response from a service which works in pyscript:
You can not only access the service API this way but the complete home assistant API which opens up a lot of possibilities in pyscript scripts ;-) |
I just tried your example, but it also yields an error in jupyther:
|
Wow, what a misleading error message. It is neither caused by '"duration": 24' nor by the fact that we requested response data. The culprit is that the entity_id does not exist. I was testing the code snippet with a calendar entity that existed on my system and replaced it with the one from your example when posting it. But while doing so I added an additional 'e' that shouldn't be there. So remove the 'e' from 'awb_koeln' then it should hopefully works. Damn Umlaute and the lack of them in English. |
Damn, I should have seen that, too. Thanks a lot for your patience with me 👍. I leave this open for the 'native' pyscript implementation, though. |
Corresponding pull request: #495 |
Thanks @matzman666 for the PR. This was just released in pyscript 1.5.0. |
Hi
I tried to use the new service responses feature of HA2023.07 with the following pyscript code:
which leads to this error:
the following YAML works fine in the develpoper tools:
Does pyscript need an update to work with the new feature?
The text was updated successfully, but these errors were encountered: