Skip to content
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

[mqtt.homeassistant] Bring Jinja template processing into compliance with Home Assistant Docs #17374

Open
ccutrer opened this issue Sep 5, 2024 · 0 comments
Assignees
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@ccutrer
Copy link
Contributor

ccutrer commented Sep 5, 2024

Right now the Home Assistant binding relies on the Jinja transformation being installed (it does not install automatically! See #6875), and can only pass value_json, not any of the additional variables documented at https://www.home-assistant.io/docs/configuration/templating/#using-templates-with-the-mqtt-integration, nor the Home Assistant specific extensions documented at https://www.home-assistant.io/docs/configuration/templating/#home-assistant-template-extensions (see #15382). Since #17356 (and #17358), we've gotten past the problem of having direct access to Jinjava in order to provide a richer "transformation" experience than the value_json of the basic Jinja transformation service, and can thus get on to addressing these issues.

The gameplan to accomplish this:

Inside of mqtt.homeassistant, implement our own internal TransformationService and TransformationServiceProvider. It will be based on the JinjaTransformationService, but will have a unique instance per component, so that the other variables can also be populated and made available to the template, and the Home Assistant extensions can be registered. And value will be populated (and value_json will only be populated if it's valid JSON) so that it will work for command templates.

For more complex components like template schema lights, I'll subclass the internal TransformationService to provide the additional variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

No branches or pull requests

1 participant