Commit Graph

191 Commits (116759f2a12e3c506f100ad0b7a4bd5ae59a8ab2)

Author SHA1 Message Date
Paulus Schoutsen 17cf53677c
Rest fixes (#61296) 2021-12-08 14:35:50 -08:00
Franck Nijhof 74d1c340d7
Allow use of relative_time as a filter (#60923) 2021-12-03 19:30:12 +01:00
Jan Bouwhuis 3188a364e2
Add template filters pack and unpack (#60836)
* add pack and unpack template filters

* Add unpack test with offset

* use unpack_from

* Simplify unpack_from statement
2021-12-03 08:58:15 +01:00
Erik Montnemery 9f4a99fe81
Revert "Add bytes support for bitwise template operations" (#60854) 2021-12-03 08:50:29 +01:00
Erik Montnemery a07f75c6b0
Revert "Allow template int filter to render from a bytes based integer" (#60855) 2021-12-02 14:37:19 -08:00
Jan Bouwhuis f07e676c82
Allow template int filter to render from a bytes based integer (#60452)
* Allow template int to render bytes

* re-triggering tests

* Add warning when base !=10 and rendering bytes

* re-trigger tests

* Re-trigger tests

* remove period

* Update homeassistant/helpers/template.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Fix logger syntax

* remove parentheses

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-30 15:01:43 +01:00
Erik Montnemery 7b57033265
Correct today_at template function / filter (#60291)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-11-24 15:51:43 +01:00
Jan Bouwhuis d33457b7bc
Add bytes support for bitwise template operations (#60211)
* Add bytes support for bitwise template operations

* spelling

* Update bitwise tests

* remove try block for bytes conversion

* do not accept empty `bytes` object
2021-11-24 15:15:27 +01:00
Jan Bouwhuis d41d223033
Add UNIX timestamp detection to `as_datetime` template filter (#60126) 2021-11-24 09:51:56 +01:00
Jan Bouwhuis fa0d3a6c48
Change output template filters `timestamp_local` and `timestamp_utc` to isoformat (#60269) 2021-11-24 09:49:03 +01:00
Marcel van der Veldt 902da4daf8
Add integration_entities template helper (#59841) 2021-11-20 14:43:31 -08:00
Chris Browet 4224cb043b
Allow overriding ensure_ascii in the "to_json" template filter (#54527)
* FIX: "ensureascii" to to_json

* fixup: parameter name
2021-11-08 15:49:10 +01:00
Marc Mueller 3f1b4906bf
Use assignment expressions 35 (#58824) 2021-10-31 18:32:17 +01:00
Erik Montnemery bed4096430
Allow specifying a super template for async_track_template_result (#58477) 2021-10-27 16:07:17 +02:00
Franck Nijhof bf693e85b1
Revert "Add warning when entity used in template doesn't exist" (#58527) 2021-10-27 13:53:26 +02:00
Petro31 11034a93c3
Add average template function and filter (#57727) 2021-10-26 22:43:45 +02:00
avee87 d9b87ee5c5
Add warning when entity used in template doesn't exist (#57316) 2021-10-22 20:09:54 +02:00
Raman Gupta e5255cf21f
Add area_entities and area_devices template functions/filters (#55228) 2021-10-22 19:59:01 +02:00
Petro31 806dc51125
Add datetime_today template method (#57435) 2021-10-22 19:51:22 +02:00
Erik Montnemery df1154395e
Revert "Swap order of int template helper kwargs (#57729)" (#58015)
This reverts commit f8dbcb953c.
2021-10-21 15:03:33 +02:00
Marc Mueller 238b488642
Use assignment expressions 03 (#57710) 2021-10-17 20:08:11 +02:00
Petro31 f8dbcb953c
Swap order of int template helper kwargs (#57729)
* swap order of int kwargs

* Add binary and kwargless base tests
2021-10-15 13:04:26 +02:00
Erik Montnemery 7acb1b6eb9
Override the jinja2 int filter (#57470) 2021-10-12 00:12:42 +02:00
Erik Montnemery ef13e473cf
Warn if template functions fail and no default is specified (#56453)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-09-29 20:16:02 +02:00
Marc Mueller 77ee72cbb9
Import Callable from collections.abc (1) (#56775) 2021-09-29 16:32:11 +02:00
Erik Montnemery 14a1bb423c
Add is_number template filter and function (#56705) 2021-09-27 10:47:57 +02:00
Chris Browet 5a2bcd2763
ADD: generalize regex_findall (#54584) 2021-09-05 12:41:39 +02:00
Raman Gupta 4d98a7e156
Allow device_id template function to use device name as input (#55474) 2021-08-31 14:56:47 +02:00
Raman Gupta 1d1b5ab345
Fix area_id and area_name template functions (#55470) 2021-08-30 13:09:41 -07:00
Raman Gupta 2f7a7b0309
Add template functions to get area_id and area_name (#54248)
* Add template function to get area_id

* fix int bug

* Prefer area name lookup

* remove unnecessary checks

* fix import

* Add area_name function

* change behavior to fail in ambiguous scenarios

* Revert lotto winning exception checking

* review comments

* try except else
2021-08-25 15:16:51 -04:00
Ville Skyttä de6e7ea016
Replace *args and **kwargs type hint collections with value types (#54955) 2021-08-21 10:20:09 +03:00
Paulus Schoutsen 1cc3ffe20d
Fix jinja warning (#54109) 2021-08-06 06:41:50 +02:00
Raman Gupta 73bc0267e9
Add DeviceRegistry template functions (#53131) 2021-07-27 18:55:55 -04:00
Franck Nijhof 4c51299dcc
Add easy converting string timestamps/dates to datetime objects in templates (#51576) 2021-06-07 15:02:15 +02:00
Matt Zimmerman e964c607a3
jinja2.contextfilter decorator renamed to pass_context (#51007)
* jinja2.contextfilter decorator renamed to pass_context

* bump jinja2 dependency
2021-05-24 17:38:37 +02:00
Ruslan Sayfutdinov 391b2f8ccd
Add missing return type in Core constructors (#50884) 2021-05-20 18:53:29 +03:00
Ruslan Sayfutdinov 6b38adaa3d
Downgrade setuptools to fix CI (#50734) 2021-05-16 20:36:23 -07:00
Marc Mueller f1d48ddfe3
Update pylint to 2.8.0 (#49637) 2021-04-24 14:39:24 -10:00
Paulus Schoutsen 1016d4ea28
Support trigger-based template binary sensors (#49504)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-04-22 14:54:28 -07:00
Marc Mueller c07646db5d
Update typing syntax (#49480)
* Update typing syntax

* Replace typing imports with ones from collections where possible

* Changes after review
2021-04-20 17:40:41 +02:00
Ville Skyttä 970cbcbe15
Type hint improvements (#49320) 2021-04-17 08:35:21 +02:00
Mike Degatano 236d274351
Add `search` and `match` as Jinja tests (#49229) 2021-04-15 20:13:27 +02:00
J. Nick Koston 82790cd28d
Do not compile static templates (#49148)
self._compiled_code is unreachable if self.is_static
2021-04-13 16:51:56 +02:00
Franck Nijhof a610076001 Support min()/max() as template function (#48996) 2021-04-12 10:02:04 +02:00
Erik Montnemery 16196e2e16
Don't log template errors from developer tool (#48933) 2021-04-09 12:10:02 -07:00
Erik Montnemery 9f5db2ce3f
Improve warnings on undefined template errors (#48713) 2021-04-06 12:11:42 -07:00
Paulus Schoutsen e882460933
Support modern config for the trigger based template entity (#48635) 2021-04-02 16:57:16 -07:00
Franck Nijhof 38d14702fa
Remove HomeAssistantType alias from helpers (#48400) 2021-03-27 12:55:24 +01:00
Franck Nijhof 6932cf9534
Use contextlib.suppress where possible (#48189) 2021-03-23 14:36:43 +01:00
Erik Montnemery f8755a52c2
Warn on undefined variables in templates (#48140)
* Warn on undefined variables in templates

* Add test

* fix tests

* fix tests
2021-03-20 15:16:04 +01:00