* 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> |
||
---|---|---|
.. | ||
fixtures | ||
__init__.py | ||
conftest.py | ||
test_alarm_control_panel.py | ||
test_binary_sensor.py | ||
test_button.py | ||
test_cover.py | ||
test_fan.py | ||
test_init.py | ||
test_light.py | ||
test_lock.py | ||
test_number.py | ||
test_select.py | ||
test_sensor.py | ||
test_switch.py | ||
test_template_entity.py | ||
test_trigger.py | ||
test_vacuum.py | ||
test_weather.py |