Are there any other alternatives besides using execute_script
to call an integration service that returns service response data? I use the returned data to populate media browsing forms in my SpotifyPlus Card component / dashboard. Some of the data can be quite lengthy, as it’s related to Spotify media catalog information.
I have users receiving unauthorized
errors when making calls to execute_script
from non-administrator accounts. Is there another way to call a service that returns service response data, and can be called by non-administrator user accounts? Note that any service calls made that do not return service response data (e.g. made via hass.callService
) are fine.
For example, here is how I currently make a call to one of my integration services (from a front-end dashboard card). For non-admin users, this will return an exception of “Unauthorized”:
// call the service as a script, so that service response data is returned.
const serviceResponse = await this.hass.connection.sendMessagePromise<ServiceCallResponse>({
type: "execute_script",
sequence: [{
"service": serviceRequest.domain + "." + serviceRequest.service,
"data": serviceRequest.serviceData,
"target": serviceRequest.target,
"response_variable": "service_result"
},
{
"stop": "done",
"response_variable": "service_result"
}]
});
// return the service response data or an empty dictionary if no response data was generated.
return serviceResponse.response || {};
The following error is logged when a non-administrator user tries to call the above:
2024-11-21 09:05:30.953 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139636436972400]
Error handling message: Unauthorized (unauthorized)
TestUser 1 NoAdmin from 192.168.1.1
(Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36)
I appreciate your consideration, and any direction you can give.
Thanks!
UPDATE
- included @petro as some searches revealed similar topics about service response variables.