-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add support for JavaScript / Jinja templates in the kiosk-mode options #274
Draft
elchininet
wants to merge
2
commits into
master
Choose a base branch
from
support_for_jinja_templates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elchininet
force-pushed
the
support_for_jinja_templates
branch
11 times, most recently
from
September 20, 2024 21:17
4a8ba0f
to
e6ce660
Compare
elchininet
changed the title
Add support for Jinja templates in the kiosk-mode options
Add support for JavaScript and Jinja templates in the kiosk-mode options
Sep 21, 2024
elchininet
changed the title
Add support for JavaScript and Jinja templates in the kiosk-mode options
Add support for JavaScript / Jinja templates in the kiosk-mode options
Sep 21, 2024
elchininet
force-pushed
the
support_for_jinja_templates
branch
2 times, most recently
from
September 22, 2024 10:51
8e299a3
to
5b4664a
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
from
September 29, 2024 22:30
5b4664a
to
ca2e950
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
from
September 30, 2024 22:11
77a6568
to
d6cc9cb
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
3 times, most recently
from
October 14, 2024 00:18
13177b6
to
d2d19f7
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
from
October 21, 2024 21:48
d2d19f7
to
b823278
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
5 times, most recently
from
November 10, 2024 14:12
2c39d47
to
7e0aecd
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
from
November 12, 2024 11:01
7e0aecd
to
5512e68
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
from
November 19, 2024 17:35
5512e68
to
11837b5
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
2 times, most recently
from
November 27, 2024 21:37
d61a056
to
fc93c9d
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
2 times, most recently
from
December 14, 2024 21:10
dca2c7b
to
6fa2035
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
from
December 25, 2024 00:06
6fa2035
to
698f173
Compare
elchininet
force-pushed
the
support_for_jinja_templates
branch
from
January 9, 2025 23:33
698f173
to
a0aa630
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is a major refactoring of the plugin and it changes radically the way of setting
kiosk-mode
options through entities state changes.1. Removal of
entity_settings
The
entity_settings
andignore_entity_settings
options have been removed.2. All the options can be booleans or
JavaScript
/Jinja
templatesExcluding
ignore_mobile_settings
andignore_disable_km
, all the options can be set as aJavaScript
or aJinja
template that returns a boolean. If you set the option as a string but it is not a valid template, the library will throw an error. If you set a template and it doesn't return a boolean, the option will be set as false and a warning will be thrown.JavaScript template example:
Jinja template example:
This solves one of the biggest issues that the plugin has: If one wants to configure entity changes for different users or for admins and non-admins the current configuration is not enough because there is a single place to configure entitites changes and it doesn't take into account users or admin privileges. With this new change it is possible to make something like this:
3. JavaScript templates use Home Assistant Javascript Templates behind the scenes
JavaScript
templates use Home Assistant Javascript Templates for theJavaScript
templating system. To know all the objects, variables and methods available in theJavaScript
templates, consult the proper section in the repository.4. Jinja templates will have access to client side variables
Inside the Jinja templates you can use some client variables that are very useful:
user_name
: String with the logged user's nameuser_is_admin
: Bolean value than indicates if the logged user is admin or notuser_is_owner
: Bolean value than indicates if the logged user is the owner or notuser_agent
: User agent of the browser in which Home Assistant is being executedAdvantages of using templates for the options
Using templates for the options gives a lot of flexibility and depending on your objectives you can omit the usage of the conditional configs, so when you start to create conditional configurations, ask yourself if it can be achieved with templates. For example:
Can be transformed into a simpler version:
5. New debug options
This pull request implements two new options:
debug
debug_template
debug
mode.debug
Example with a valid template
Example with an invalid template
debug_template