You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/_docs/configuration/templating.markdown
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,9 @@ Home Assistant adds extensions to allow templates to access all of the current s
69
69
- `is_state('device_tracker.paulus', 'home')`will test if the given entity is specified state.
70
70
- `is_state_attr('device_tracker.paulus', 'battery', 40)`will test if the given entity is specified state.
71
71
- `now()`will be rendered as current time in your time zone.
72
+
- For specific values: `now().second`, `now().minute`, `now().hour`, `now().day`, `now().month`, `now().year`, `now().weekday()` and `now().isoweekday()`
72
73
- `utcnow()`will be rendered as UTC time.
74
+
- For specific values: `utcnow().second`, `utcnow().minute`, `utcnow().hour`, `utcnow().day`, `utcnow().month`, `utcnow().year`, `utcnow().weekday()` and `utcnow().isoweekday()`.
73
75
- `as_timestamp()`will convert datetime object or string to UNIX timestamp
74
76
- `distance()`will measure the distance in meters between home, entity, coordinates.
75
77
- `closest()`will find the closest entity.
@@ -89,6 +91,10 @@ Home Assistant adds extensions to allow templates to access all of the current s
89
91
If your template uses an `entity_id` that begins with a number (example: `states.device_tracker.2008_gmc`) you must use a bracket syntax to avoid errors caused by rendering the `entity_id` improperly. In the example given, the correct syntax for the device tracker would be: `states.device_tracker['2008_gmc']`
90
92
</p>
91
93
94
+
<p class='note warning'>
95
+
Rendering templates with time is dangerous as updates only trigger templates in sensors based on entity state changes.
96
+
</p>
97
+
92
98
## {% linkable_title Home Assistant template extensions %}
93
99
94
100
In templates, besides the normal [state object methods and properties](/topics/state_object/), there are also some extra things available:
0 commit comments