fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

Franck Nijhof

🚀 𝗖𝗮𝗹𝗹𝗶𝗻𝗴 𝗮𝗹𝗹 𝗛𝗼𝗺𝗲 𝗔𝘀𝘀𝗶𝘀𝘁𝗮𝗻𝘁 𝘁𝗲𝗺𝗽𝗹𝗮𝘁𝗲 𝘄𝗶𝘇𝗮𝗿𝗱𝘀! 🧙‍♂️

I’m working on extending the template engine with some new functions, filters, and tests, for example:

✅ flatten(list_of_lists) – Flattens nested lists into a single list
✅ combine(dict1, dict2, ...) – Merges multiple dictionaries together

Now, I need your input! 💡

🔍 What template functions, filters, or tests would make your automations easier?
💬 What repetitive Jinja gymnastics do you find yourself doing over and over?

@frenck I find the

(as_timestamp(now()) - as_timestamp(state_attr("automation.xxx", "last_triggered"), 0)

quite lengthy.

Could we get a "seconds_since()" (implied: relative to now) or a "timestamp_diff()" instead?

@larsmb @frenck I was about to say thanks but I can't think of anything, but yes date time manipulation would be lovely.

There may already be a better way of doing this, but I couldn't find it so I have this brute

{% set t = (as_local(now()) - as_local(as_datetime(states('input_datetime.dishwasher_start_time')))).total_seconds() -120 %}

@frenck two that I created for my instance was "floor_entities" and "floor_devices". Should be self explanatory. :)

@frenck My biggest #Jinja gripe, in HA context, is unavailable/unknown. Semantically these aren't really values. In creating a template sensor for the difference of two temperatures, I have to check for them, and in general there are a lot of if foo not unavailable and foo not unknown.

What I would like is propagation, so that any template whose output expression has used a variable that is unknown has value unknown, and then similarly for unavailable.