Skip to article frontmatterSkip to article content
Reference

Provided Home Assistant template functions, filters, and tests

How did those functions break up❓ They stopped calling each other πŸ₯

Spook provides quite a lot of new template functions, filters, and tests to the Home Assistant template engine. This reference page lists them all and points you to the right documentation for each of those template functions.

FlattenΒΆ

Flatten a lists of lists.

{{ flatten(["a", ["b", ["c"]]]) }}
{{ flatten(["a", ["b", ["c"]]], levels=1) }}

documentation πŸ“š

MD5ΒΆ

Calculate the MD5 hash of a given value.

{{ md5("hash me") }}

documentation πŸ“š

SHA1ΒΆ

Calculate the SHA1 hash of a given value.

{{ sha1("hash me") }}

documentation πŸ“š

SHA256ΒΆ

Calculate the SHA256 hash of a given value.

{{ sha256("hash me") }}

documentation πŸ“š

SHA512ΒΆ

Calculate the SHA512 hash of a given value.

{{ sha512("hash me") }}

documentation πŸ“š

ShuffleΒΆ

Shuffles a list of items.

{{ shuffle(["a", "b", "c"]) }}
{{ shuffle(["a", "b", "c"], seed=42) }}

documentation πŸ“š

TypeofΒΆ

Reveals the type of a given value.

{{ typeof("Spook") }}
{{ now() | typeof }}

documentation πŸ“š

Unix file name pattern filteringΒΆ

Filter a lists of texts against a pattern.

{{ fnmatch_filter(["Spook", "Ghost], "Sp*k") }}
{{ fnmatch_filter(["Spook", "Spook2", "Ghost"], "Sp*") }}

documentation πŸ“š

Unix file name pattern matchingΒΆ

Match text or a lists of texts against a pattern.

{{ fnmatch("Spook", "Sp*k") }}
{{ fnmatch(["Spook", "Spook2"], "Sp*") }}

documentation πŸ“š