Commit Graph

252 Commits

Author SHA1 Message Date
David Poll
2215777cfb Fix zero-argument functions with as_function (#150062) 2025-08-06 15:20:03 +02:00
Petro31
97f3bb3da5 Add default to from_json (#146211) 2025-06-24 14:27:14 +02:00
Petro31
e494f66c02 Add label_description to template engine (#147138)
Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
2025-06-23 19:21:29 +01:00
David Poll
670e8dd434 Add as_function to allow macros to return values (#142033) 2025-05-26 20:22:45 +02:00
David Poll
13d7234f97 Add apply to make macros/callables useful in filters and tests (#144227) 2025-05-26 17:00:07 +02:00
Petro31
13a6c13b89 Allow base64_encode to support bytes and strings (#145227) 2025-05-26 13:56:11 +02:00
Petro31
25f3ab3640 Add from_hex filter (#145229) 2025-05-26 13:16:56 +02:00
Simone Chemelli
484a547758 Fix pylance warning on SnapshotAssertion import (#145206) 2025-05-19 13:55:48 +02:00
Paul Bottein
8ec436423f Add template function: device_name (#142683) 2025-04-14 14:30:00 +02:00
Franck Nijhof
eb1caeb770 Add template list functions: intersect, difference, symmetric_difference, union (#141420) 2025-03-26 07:51:25 +01:00
Franck Nijhof
c6d3928ed1 Add template function: combine (#140948)
* Add template function: combine

* Add test to take away concern raised
2025-03-20 10:29:40 +01:00
Franck Nijhof
e8069e1c07 Add template functions: md5, sha1, sha256, sha512 (#140192) 2025-03-09 16:15:27 +02:00
Franck Nijhof
9aa8a786a5 Add template function: flatten (#140157) 2025-03-08 11:14:27 -10:00
Franck Nijhof
e54febdc1e Add template function: typeof (#140081) 2025-03-08 09:16:21 -10:00
Franck Nijhof
d4f205c366 Add template function: shuffle (#140077) 2025-03-07 20:36:17 -05:00
Erik Montnemery
cc5c8bf5e3 Make helpers.frame.report_usage work when called from any thread (#139836)
* Make helpers.frame.report_usage work when called from any thread

* Address review comments, update tests

* Add test

* Update test

* Update recorder test

* Update tests
2025-03-05 19:37:34 +01:00
Petro31
a296c5e9ad Add floor_entities function and filter (#136509)
Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
2025-02-28 11:44:01 +00:00
epenet
364556a7dd Prefer from...import...as over import...as in core tests (#136146) 2025-01-21 09:28:17 +01:00
Erik Montnemery
235fda55fe Validate config entry when adding or updating entity registry entry (#135067) 2025-01-17 19:18:13 +01:00
Petro31
566f514a75 Allow is_state_attr to check attributes for None (#132879) 2025-01-17 08:41:10 +01:00
Michael Arthur
d8549409f7 Area units and conversion between metric and US (#123563)
* area conversions

* start work on tests

* add number device class

* update unit conversions to utilise distance constants

* add area unit

* update test unit system

* update device condition and trigger

* update statistic unit converters

* further tests work WIP

* update test unit system

* add missing string translations

* fix websocket tests

* add deprecated notice

* add more missing strings and missing initialisation of unit system

* adjust icon and remove strings from scrape and random

* Fix acre to meters conversion

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Tidy up valid units

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* fix ordering of area

* update order alphabetically

* fix broken test

* update test_init

* Update homeassistant/const.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* remove deprecated unit and fix alphabetical order

* change deprecation and add tests, change to millimeter conversion for inches

* fix order

* re-order defs alphabetically

* add measurement as well

* update icons

* fix up Deprecation of area square meters

* Update core integrations to UnitOfArea

* update test recorder tests

* unit system tests in alphabetical

* update snapshot

* rebuild

* revert alphabetization of functions

* other revert of alphabetical order

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2024-11-21 16:10:44 +01:00
epenet
be4641b8f3 Push real binary sensor states to state machine in tests (#128894) 2024-10-21 16:19:25 +02:00
G Johansson
959898e0fc Fix merge_response template not mutate original object (#127865)
* Fix merge_response template not mutate original object

* Add comment
2024-10-08 18:35:06 +02:00
Erik Montnemery
851600630c Log deprecation warning when template.Template is created without hass (#125142)
* Log deprecation warning when template.Template is created without hass

* Improve docstring
2024-09-03 14:28:33 +02:00
G Johansson
78cf7dc873 New template merge_response (#114204)
* New template merge_response

* Extending

* Extend comment

* Update

* Fixes

* Fix comments

* Mods

* snapshots

* Fixes from discussion
2024-09-02 08:13:10 +02:00
J. Nick Koston
0a9e20615e Limit maximum template render output to 256KiB (#124946)
* Limit maximum template render output to 256KiB

fixes #124931

256KiB is likely to still block the event loop for an unreasonable amont of
time but its likely someone is using the template engine for large
blocks of data so we want a limit which still allows that but has
a reasonable safety to prevent the system from crashing down

* Update homeassistant/helpers/template.py
2024-08-30 22:33:57 +02:00
Petro31
5d64155bb6 Add zip to template engine (#122460)
* add zip to template engine

* fix doc strings
2024-08-22 19:11:08 +02:00
Paulus Schoutsen
bc45dcbad3 Add template config_entry_attr function (#119899)
* Template config_entry_attr function

* Complete test coverage

* Improve readability
2024-06-22 21:51:09 -04:00
G Johansson
127af149ca Remove legacy template hass config option (#119925) 2024-06-21 12:53:55 +02:00
epenet
38a6e666a7 Add missing return type to some test functions (#119665) 2024-06-14 08:26:45 +02:00
epenet
20817955af Fix bad-chained-comparison pylint warning in tests (#119477) 2024-06-12 12:35:55 +02:00
Sid
721b2c2ca8 Enable Ruff PT012 (#113957) 2024-06-08 17:59:08 +02:00
paulusbrand
624017a0f9 Add template Base64 decode encoding parameter (#116603)
Co-authored-by: Robert Resch <robert@resch.dev>
2024-06-07 17:01:35 +02:00
J. Nick Koston
c9d1b127d8 Improve error message when template is rendered from wrong thread (#117822)
* Improve error message when template is rendered from wrong thread

* Improve error message when template is rendered from wrong thread
2024-05-20 23:26:48 -04:00
J. Nick Koston
5a609c34bb Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
Troon
cc99a9b62a Add an add template filter (#109884)
* Addition of add filter

This change adds an `add` filter, the addition equivalent of the existing `multiply` filter.

* Test for add filter

* Update test_template.py

* Update tests/helpers/test_template.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-08 15:39:36 +02:00
Sid
e662e3b65c Bump ruff to 0.4.2 (#116201)
* Bump ruff to 0.4.2

* review comments
2024-04-26 08:48:32 +02:00
Erik Montnemery
6bff0c384f Remove deprecation warnings for relative_time (#116144)
* Remove deprecation warnings for relative_time

* Update homeassistant/helpers/template.py

Co-authored-by: Simon <80467011+sorgfresser@users.noreply.github.com>

---------

Co-authored-by: Simon <80467011+sorgfresser@users.noreply.github.com>
2024-04-25 13:02:18 +02:00
Erik Montnemery
2e88ba40ff Fix lying docstring for relative_time template function (#116146)
* Fix lying docstring for relative_time template function

* Update homeassistant/helpers/template.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-25 13:01:41 +02:00
rlippmann
1120246194 Deprecate relative_time() in favor of time_since() and time_until() (#111177)
* add time_since/time_until.  add deprecation of relative_time

* fix merge conflicts

* Apply suggestions from code review

* Update homeassistant/helpers/template.py

* Update homeassistant/helpers/template.py

* Update homeassistant/helpers/template.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-04-24 11:13:07 +02:00
J. Nick Koston
53a179088f Add debug mode to catch unsafe thread operations using core helpers (#115390)
* adjust

* adjust

* fixes

* one more

* test

* debug

* move to config

* cover

* Update homeassistant/core.py

* set debug from RuntimeConfig

* reduce

* fix message

* raise

* Update homeassistant/core.py

* Update homeassistant/core.py

* no flood check for raise

* cover
2024-04-24 03:36:05 +02:00
Martijn van der Pol
e90d76b18d Don't raise errors when using datetime objects in as_datetime Jinja function/filter (#109062)
* add support for datetime objects to as_datetime

* change import of datetime.date

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-04-23 09:55:58 +02:00
J. Nick Koston
33412dd9f6 Remove unused legacy state translations (#112023)
* Remove unused state translations

There have been replaced with entity translations
https://github.com/home-assistant/developers.home-assistant/pull/1557
https://github.com/home-assistant/core/pull/82701

* nothing does merging anymore

* useless dispatch

* remove

* remove platform code from hassfest

* preen

* Update homeassistant/helpers/translation.py

* ruff

* fix merge

* check is impossible now since we already know if translations exist or not

* keep the function for now

* remove unreachable code since we filter out `.` before now

* reduce

* reduce

* fix merge conflict (again)
2024-04-14 07:13:17 -04:00
Sid
d61db732da Enable Ruff SLOT rules (#115043) 2024-04-09 18:57:27 -10:00
Sid
9cbed10372 Enable Ruff PYI041 (#115229) 2024-04-08 09:29:05 -10:00
Robert Resch
7adced6876 Allow passing area/device/entity IDs to floor_id and floor_name (#114748) 2024-04-03 16:33:58 +02:00
Franck Nijhof
5c69e0d2c6 Add label template functions (#111024) 2024-03-26 10:32:29 +01:00
Franck Nijhof
fc6a83559f Add floor template functions (#110847) 2024-03-20 11:58:04 +01:00
Sid
00ec7f11f0 Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
Marc Mueller
19ab3d6daf Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00