Last active
March 5, 2020 14:50
-
-
Save AlexxIT/c0f3dff945ee2f9154e99864a14d8174 to your computer and use it in GitHub Desktop.
Extend Home Assistant jinja2 Templates
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
# положи меня /config/custom_components/__init__.py | |
# но лучше не страдай х..нёй и поставь Node-RED | |
import urllib.parse | |
from homeassistant.helpers import template | |
_TemplateEnvironment = template.TemplateEnvironment | |
def unquote(value): | |
""" {{ '%20тест%5Bжанр%5D'|unquote }} """ | |
return urllib.parse.unquote(value) | |
def monkey(*args): | |
env = _TemplateEnvironment(*args) | |
env.filters['unquote'] = unquote | |
return env | |
template.TemplateEnvironment = monkey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment