1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-31 20:54:23 +01:00
Files
core/tests/components
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
..
2022-04-20 08:56:05 +02:00
2022-03-30 11:26:08 +02:00
2022-03-22 21:01:24 -07:00
2022-03-26 09:50:50 -10:00
2022-04-11 16:51:13 +02:00
2022-03-20 20:34:02 -07:00
2022-04-01 15:11:37 +02:00
2022-03-30 11:26:08 +02:00
2022-03-30 12:15:04 +02:00
2022-03-30 12:15:04 +02:00
2022-03-30 12:15:04 +02:00
2022-03-30 16:15:34 +02:00
2022-03-30 11:26:08 +02:00
2022-04-18 16:27:14 +02:00
2022-04-14 15:29:31 -07:00
2022-03-16 10:18:55 +01:00
2022-04-12 14:10:54 -07:00