Skip to content

Commit

Permalink
Merge pull request #25 from PiotrMachowski/dev
Browse files Browse the repository at this point in the history
v1.2.1
  • Loading branch information
PiotrMachowski authored Sep 30, 2023
2 parents 75fb2e2 + efb3ebe commit f6f4de7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions custom_components/saver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def setup_templates(hass: HomeAssistant) -> None:
def is_safe_callable(self: TemplateEnvironment, obj) -> bool:
# noinspection PyUnresolvedReferences
return (isinstance(obj, (SaverVariableTemplate, SaverEntityTemplate))
or self.saver_original_is_safe_callable_old(obj))
or self.saver_original_is_safe_callable(obj))

def patch_environment(env: TemplateEnvironment) -> None:
env.globals["saver_variable"] = SaverVariableTemplate(hass, f"{DOMAIN}.{DOMAIN}")
Expand All @@ -89,10 +89,13 @@ def patched_init(
self.saver_original__init__(hass_param, limited, strict, log_fn)
patch_environment(self)

TemplateEnvironment.saver_original__init__ = TemplateEnvironment.__init__
TemplateEnvironment.__init__ = patched_init
TemplateEnvironment.saver_original_is_safe_callable_old = TemplateEnvironment.is_safe_callable
TemplateEnvironment.is_safe_callable = is_safe_callable
if not hasattr(TemplateEnvironment, 'saver_original__init__'):
TemplateEnvironment.saver_original__init__ = TemplateEnvironment.__init__
TemplateEnvironment.__init__ = patched_init

if not hasattr(TemplateEnvironment, 'saver_original_is_safe_callable'):
TemplateEnvironment.saver_original_is_safe_callable = TemplateEnvironment.is_safe_callable
TemplateEnvironment.is_safe_callable = is_safe_callable

tpl = Template("", hass)
tpl._strict = False
Expand Down
2 changes: 1 addition & 1 deletion custom_components/saver/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "calculated",
"issue_tracker": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Saver/issues",
"requirements": [],
"version": "v1.2.0"
"version": "v1.2.1"
}

0 comments on commit f6f4de7

Please sign in to comment.