* feat: make this variable available in template entities This makes the variable `this` available in template entities. It will simplify the use of self-referencing template entities. Because, without this, we have to repeat the entity id every time. If we can solve this without explicitly spelling the entity id, code can be re-used much better. As a side-effect, this will allow to use `variables`-like patterns, where attributes can be used as variables to calculate subsequent attributes or state. Example: ```yaml template: sensor: - name: test state: "{{ this.attributes.test }}" # not: "{{ state_attr('sensor.test', 'test' }}" attributes: test: "{{ now() }}" ``` * expose entity_id instead of this * add test * Refactor to expose this variable * Tweak repr dunder Co-authored-by: Erik <erik@montnemery.com> |
||
---|---|---|
.. | ||
auth | ||
backports | ||
components | ||
fixtures | ||
hassfest | ||
helpers | ||
pylint | ||
resources | ||
scripts | ||
test_util | ||
testing_config | ||
util | ||
__init__.py | ||
bandit.yaml | ||
common.py | ||
conftest.py | ||
ignore_uncaught_exceptions.py | ||
test_bootstrap.py | ||
test_config.py | ||
test_config_entries.py | ||
test_core.py | ||
test_data_entry_flow.py | ||
test_exceptions.py | ||
test_loader.py | ||
test_main.py | ||
test_requirements.py | ||
test_runner.py | ||
test_setup.py | ||
test_test_fixtures.py |