Closed johnwelford closed 4 weeks ago
We have non-Administrators using the application just fine. Your steps for recreating the bug may well not work for another JSON file. We know from previous experience that issues have been localised to a specific menu item.
This may well be a show stopper. We did not expect Administrator priviledges to be getting in the way either. There is absolutely no promise this can be fixed.
I have a similar issue. All my toggles/switches work fine, but once I wanted to add a template, every time I open the app on the watch, a 401 error appears.
{
"entity": "sensor.a1_03919c430600775_verbleibende_zeit",
"name": "Time Left",
"type": "template",
"content": "{{ states('sensor.a1_03919c430600775_verbleibende_zeit') }}"
},
The web viewer underlines the entity name as it does with any other entity (which works) in the menu file. All my other entities (toggles) work from the web viewer too, but pressing "Render Template" just causes the screen to gray out and having to press "Test API" in the Troubleshooting window again to be able to edit the template again. I don't know what's going on since I can view the entity just fine on the actual website.
I think that the issue is that we are using the REST API for rendering templates which requires admin, the webhook API may not have the same requirements: https://developers.home-assistant.io/docs/api/native-app-integration/sending-data#render-templates.
That's interesting design on HA's side, why would that require admin? I can try and switch to an admin account if that helps.
This confirms that admin is required for the REST endpoint:
class APITemplateView(HomeAssistantView):
"""View to handle Template requests."""
url = URL_API_TEMPLATE
name = "api:template"
@require_admin
async def post(self, request: web.Request) -> web.Response:
"""Render a template."""
try:
data = await request.json()
tpl = _cached_template(data["template"], request.app[KEY_HASS])
return tpl.async_render(variables=data.get("variables"), parse_result=False) # type: ignore[no-any-return]
except (ValueError, TemplateError) as ex:
return self.json_message(
f"Error rendering template: {ex}", HTTPStatus.BAD_REQUEST
)
So odd. Is there a way to just retrieve the state of the sensor without rendering that within a template? What would the best approach be for fixing this, either here through some workarounds or bugging some HA developers?
We have an idea. We can swap the template HTTP calls to webhooks, which we are already using for some other bits of the functionality.
That would be awesome!
Error code 401 being returned for non-administrator user.
I have:
To Reproduce
Expected behavior Did not expect that administrator level user account was necessary
Garmin Device (please complete the following information):
Smartphone (please complete the following information):
Additional context Similar to issue 39, but without battery reporting being turned on?