Allow jinja namespace command to work. (#18011)
This commit is contained in:
parent
4d9ef9e795
commit
865ea82432
2 changed files with 23 additions and 0 deletions
|
@ -9,6 +9,7 @@ import re
|
|||
import jinja2
|
||||
from jinja2 import contextfilter
|
||||
from jinja2.sandbox import ImmutableSandboxedEnvironment
|
||||
from jinja2.utils import Namespace
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_LATITUDE, ATTR_LONGITUDE, ATTR_UNIT_OF_MEASUREMENT, MATCH_ALL,
|
||||
|
@ -618,6 +619,11 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment):
|
|||
"""Test if callback is safe."""
|
||||
return isinstance(obj, AllStates) or super().is_safe_callable(obj)
|
||||
|
||||
def is_safe_attribute(self, obj, attr, value):
|
||||
"""Test if attribute is safe."""
|
||||
return isinstance(obj, Namespace) or \
|
||||
super().is_safe_attribute(obj, attr, value)
|
||||
|
||||
|
||||
ENV = TemplateEnvironment()
|
||||
ENV.filters['round'] = forgiving_round
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue