I’m begrudgingly moving all of my switch templates to template switches due to the deprecation coming in 2026.6. This is exhibiting an unusual behavior however:
Turn switch on
Associated devices turn on immediately
Template switch turns back off
Everything sits like this until the logs show action for “Trigger Update Coordinator” and then the template switch changes state to on.
Well I appreciate that pointer. It does change the behavior but also changes the control widget from a radio slider to two buttons, one representing on and the other off.
Maybe try customize: (docs) and assumed_state: true (docs), I have changed switches from 2 button to a toggle using this, just make sure to keep customize under the homeassistant: key.
Thanks. I’ll play with that. I took the state template and put it into the template editor to watch. As soon as I turn off the template switch, both switches turn off and they both reflect turned off in HA. When I look at the template value in the dev tools it shows the state immediately changes from True to False. I suspect there is more to this.
Probably worth noting it does not behave like this using the platform template integration under switch. Only under the now-required switch integration for template. Deprecation of legacy template entities in 2025.12
It doesn’t use optimistic: true so its UI presentation is a toggle.
For this particular application, the default_entity_id option isn’t required because the desired value (switch.office_light) will be automatically derived from name (Office Light).
I like the little flair of mad genius there but I don’t get your result. Instead I get the error:
Failed to perform the action switch/turn_on. Error rendering service target template: UndefinedError: 'switches' is undefined
It’s clearly not recognizing the variable. (A technique I’ve never seen or used before.) Are these variables scoped to the individual device entry? I’ll dig to see if perhaps I have to enable another feature or version to make use of this but I’m on 2026.3.
A couple restarts and the error went away and it started calling the service to turn on/off. However I’m seeing a delay there as well. I know you said you do not get that.
I think that’s the best and only option at this point.
If the problem still occurs in 2026.4 then it’s unique to your system (I cannot reproduce it on mine; the example I posted works flawlessly on my system).
According to the documentation, if you intend on listing different platforms (switch, light, binary_sensor, etc) under the template: key, then the examples it provides look like this (note the hyphen next to each platform name).
the legacy templates and modern templates use the exact same guts under the hood. So what you’re saying isn’t possible. They will behave the exact same way.
If your switch is immediately turning off, that means the state template isn’t updating and there’s a delay in your source entities showing the state. You can do what @HappyCadaver by adding optimistic.
If it changed your light to two lightning bolts, that definitely means your state template isn’t updating because it can’t find the state. After you turn it on, the lightning bolts will change to a toggle as it will now know the state.
Here’s a video to show it in action. https://youtu.be/w9lwof42Bmw I created a single page with all three sensors (old switch, new template switch, and the variable example above) as well as both devices. I also put up a tail of the log as well as the template rendered under dev tools.
You can see:
(Well you can’t see this but) the lights are turning on and off with the associated devices.
The template renders immediately when I turn on and off the old switch template.
Both the new template switch and the variable based one are delayed.
Both devices turn on and off immediately.
Only the new devices are flip-flopping.
The log shows exactly when they update properly and it’s when the Trigger Update Coordinator logs.
I did update to 2026.4 though that didn’t change anything in this behavior. I’m game to try any suggestions but right now the new hotness isn’t getting me there for some reason. If there are other state templates I should try I’m happy to do so but I’m at a loss for what. Maybe try “on/off” instead of “true/false”?
Oh I might add, the two devices are on two different integrations. The AN163 is a zwave device connected via mqtt and the TPlink device is wifi through their integration.
Post the configuration. Remember you’re talking to the developer, I am 100% sure they run exactly the same code. I have test cases that literally test all features the exact same way.
Sending in a moment. I do appreciate you looking at it and when I say PII I mean removing my kids names, passwords and geo locations. No chance I’d ever share that even with someone helping me in good faith. But otherwise it’s the whole thing.
in situations like this, you need to separate entities from triggers otherwise they only update when the trigger updates. To do that, you add a dash before the switch to make it a separate template entry.
Well that explains why the posted example didn’t have a hyphen before the switch key. It was not the configuration of a Template Switch but a Trigger-based Template Switch.
Unfortunately they never replied to my post, explaining why their configuration’s switch key lacked the hyphen. It would have solved this mess quicker.