#Template engine

1 messages · Page 1 of 1 (latest)

stoic apex
#

Chat channel around the development of the Home Assistant template engine, which is build around Jinja2

stoic apex
scarlet pier
stoic apex
kindred hedge
#

The gif tab in discord

scarlet pier
#

Taxi 2 🙂
A great French comedy 😉

#

Directed by : Gérard Krawczyk
Produced by : ARP Sélection, EuropaCorp
Genre: Fiction - Runtime: 1 h 22 min
French release: 29/03/2000
Production year: 1999

The Japanese Minister of Defence is in town to test French know-how when it comes to anti-terrorism. He'll also sign "the contract of the century" with the French government. But then ...

▶ Play video
stoic apex
#

Check, I've seen those movies 😄

elder moat
#

Is this the right spot to chat about template entity blueprints? I tried porting some of my template entities to blueprints to share, but then noticed a bunch of gaps (e.g. triggers, etc) and wanted to make sure i'm not just doing it wrong, and confirm there are some gaps we have yet to implement. (before i dive in to fill some gaps, wanted to make sure i'm not missing something)

#

I also know we have some plans to simplify triggers/conditions so also could pause if there is more to play out there

scarlet pier
#

Things like “when a leak is detected in the first floor” or “if a window is open in the office” or “when a switch with the label always_on turns off”

worn geode
#

I've filled most of the gaps in the last 2 releases

#

Theres 2 gaps that I plan on filling:

  1. trigger_variables
  2. Blueprints in the UI ( no idea how to go about this yet, might just do it through config flow)
#

Outside those 2 gaps, template entities via blueprints seem like they are in an "decent" place. Aside from all the template entities that need to be ported over to modern style, which I'm working on

#

FYI, at the rate we are currently going, it's likely going to be a year or so before all platforms are fully ported to modern style because it's only Eric and I doing the work/reviewing

elder moat
#

I think maybe its just missing template expansion for the actions

worn geode
#

what do you mean template expansion?

#

so that should work in the latest version of HA

#

Just understand that variables are executed between triggers and actions

elder moat
#

ok, i last looked two weeks ago before the last release

#

There are a lot of good LLM-ish things that are ready for template entity blueprints so wanted to make a bunch and share with the community

worn geode
worn geode
elder moat
worn geode
#

so basically, before 2025.4 the variables section was completely ignored with trigger based template entities.

elder moat
worn geode
#

yah, - platform: is old template styles

elder moat
#

Do you have an example PR of modernizing a platform? just could save me a minute of searching

worn geode
#

I have a few

#

so, let me explain a bit first

#

moving from legacy to modern requires 2 or 3 PRs and it depends on the platform

#

for example, switch only needs 2, light needs 3

#

the goal is to keep functionality identical between legacy, modern, and trigger style templates

#

so, PR1 is adding modern style

#

PR2 (optional) adds a base class that can be used for both trigger and non-trigger based entities

#

PR3 adds trigger based functionality

elder moat
#

Awesome, appreciate the "lay of the land"

worn geode
#

Light -> 3PRs
PR1: To modern -> https://github.com/home-assistant/core/pull/140326
PR2: Common Class -> https://github.com/home-assistant/core/pull/140588
PR3: Trigger based -> https://github.com/home-assistant/core/pull/140631

Switch -> 2PRs
PR1: To modern -> https://github.com/home-assistant/core/pull/140324
PR2: Trigger based -> https://github.com/home-assistant/core/pull/141763

Cover -> maybe 3 PRs??? Haven't figured that out yet.
PR1: To modern -> https://github.com/home-assistant/core/pull/141878

#

The hardest part about these are the tests

#

So, the updating to modern style takes me like 15 minutes at the moment, but the tests take 4 or 5 hours because they are all different. Every platform was added by a different person and it shows in the tests. Some of them make sense, some do not. So I've been adding common "theme" to all the tests, which is still a work in progress. I'll likely add common fixtures at some point.

#

I likely have to make changes to both switch and light trigger PRs to account for the changes in the resolution order.

#

last last thing, eric is on vacation and he's the only core team member who isn't afraid to review template integration PRs 🤣

elder moat
#

fantastic. that's a much richer response than i was expecting, thank you.

worn geode
worn geode
worn geode
worn geode
#

@stoic apex what are your thoughts on making states() return native types in combination with an automated system (for UI entities) that makes an availability template based on update entities for the template?

stoic apex
#

as this would be extremely breaking for anything existing

#

I have considered it before myself as well

#

which resulted in my drive for the POC for an alternative syntax at the time

worn geode
#

Ok, then plan 2 would be a new method for native types and an additional property on the TemplateStates object for native types

#

non-native types is a major pain point in templating, anything we can do to mitigate the issue is sorely needed

kindred hedge
#

the_cooler_states()

drowsy trench
#

Or just state()? cuz it never made sense for it to be plural

worn geode
#

get out of here with your logic

#

but yes, I thought about that. Might be confusing though