hass-core/homeassistant
akloeckner d20a620590
Make this variable available in template entities (#65201)
* 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>
2022-04-20 15:30:17 +02:00
..
auth Improve typing [util.decorator] (#67087) 2022-02-23 20:58:42 +01:00
backports Cleanup after pylint update (#68657) 2022-03-26 00:34:12 +01:00
components Make this variable available in template entities (#65201) 2022-04-20 15:30:17 +02:00
generated Narrow down the list of LIFX models for HomeKit discovery (#70125) 2022-04-16 10:08:44 -10:00
helpers Make this variable available in template entities (#65201) 2022-04-20 15:30:17 +02:00
scripts Remove EVENT_TIME_CHANGED and EVENT_TIMER_OUT_OF_SYNC (#69643) 2022-04-09 09:05:54 -10:00
util Switch to using ULIDs for context_ids (#70246) 2022-04-18 22:45:41 -07:00
__init__.py
__main__.py
block_async_io.py Add type ignore error codes [core] (#66773) 2022-02-17 23:09:22 -08:00
bootstrap.py Revert "Block peer certs on supervisor" (#67104) 2022-02-23 12:32:07 +01:00
config.py Adjust "default_config" comment in default config (#68679) 2022-03-28 09:03:34 -07:00
config_entries.py Fix _abort_if_unique_id_configured updates type hint (#68730) 2022-03-29 09:24:15 +02:00
const.py Add for each item support to repeat action (#70093) 2022-04-15 19:10:25 +02:00
core.py Switch to using ULIDs for context_ids (#70246) 2022-04-18 22:45:41 -07:00
data_entry_flow.py Make initial group config flow step a menu (#68565) 2022-03-23 08:34:44 -07:00
exceptions.py Report unmet dependencies for failing config flows (#65061) 2022-02-02 15:06:27 +01:00
loader.py Add integration type (#68349) 2022-03-20 20:38:13 -07:00
package_constraints.txt Update Pillow to 9.1.0 (#70273) 2022-04-19 12:49:43 +02:00
requirements.py
runner.py Add type ignore error codes [core] (#66773) 2022-02-17 23:09:22 -08:00
setup.py Highlight in logs it is a custom component when setup fails (#67559) 2022-03-03 15:03:03 -08:00
strings.json