Are you saying that you are trying to test the triggers in the Template Editor (like shown in your screenshot)? Because you cannot test them like that. The Template Editor is only for testing templates, not entire automations and scripts.
I tested the isolated template in the editor and since it gave the value “true”, as I was a bit desperate, I tested the entire automation to see what would happen.
I’m sorry, I don’t know how to name the message.
Regards
Your Template Trigger fires when its template evaluates to true after previously having been false. It’s the transition from false to true that causes it to trigger.
Once it’s true, if any of the temperatures in the template change but the template continues to report true then it will not trigger again. It first has to evaluate to false before changing to true in order to trigger again.
You are absolutely right, even if the target temperature varies, the result is never “false”. I have no idea where the bug is.
I have been with HA alone for two months and this is very big for me. Previously I tried with scripts but I immediately realized that the solution is the templates, but I am unable
The bug is that this is the wrong trigger for your automation. Its value will never change to false and without changes automations don’t trigger. You could use a simple State trigger based on the “current_temperature” attribute. By leaving the “to” and “from” fields blank it would trigger on every state change. This can be useful for some automations, but it can cause the device to bounce between on and off which is generally not a good idea electro-mechanical devices. Instead, try using a template in a Numeric State trigger. To avoid turning the valves on and off too often, the example below looks for a difference of at least 2˚ which is sustained for 5 minutes.
Thank you very much, what you have done is very logical but it has not worked, the automation has not been triggered. I have tried to check in the template editor and it says this (I don’t even know if I’m checking it well, sorry)
Curious, that automation is pretty much straight from the Numeric State trigger docs so I assumed it would work… but I’ve now tried multiple variations, and I can’t get it to trigger either.
Why it fails to trigger is probably because the Numeric State Trigger is monitoring changes to the climate entity’s state value, not its attributes. The state value of a climate entity isn’t numeric, it’s a string like heat, cool, auto, off, etc.
Thank you very much, you are patient, thank you very much. The sensor is created and changes from true to false when I put a difference of 2 in the target temperature but it still does not trigger the automation. I think the sensor template is fine but for something it does not trigger it
Is there a way that I refer to the attribute instead of the mode (heating, off, …)?
Thank you very much for the answers and the attempts. With the normal integrations and automations I have done relatively well but the templates without knowing how to program seem impossible and the documentation that I find does not get me out of trouble, I am totally lost.
On top of that I am going on a trip and I will not be able to do any tests until Monday, I hope to come inspired.
Thank you very much again
When using the old template sensor format you would have to name it like that, but the current method automatically converts the name to its equivalent entity id turning " " into “_” and making everything lowercase.
When you get back to it, make testing easier on yourself by reducing the “for:” to 30 seconds or a minute… that way you don’t have to sit there waiting.
Hello again.
I’m stuck in the same place, I’ve been testing all week and the worst thing is that in one of those tests the automation was triggered, I made some changes in the action and it never worked again. The code I used was the first one that Didgeridrew put in:
Fixed at the end !!! I thought that the template had stopped working but it was that it had to start from a difference of less than one (negative) to more than 1 to trigger the automation.
Everything perfect!!! thank you all very muc!!!, I was going crazy
Yes, among the 3 you have achieved the solution, regards for you three.
I don’t know how to do it : Who should mark the solution?, or should write the code in another message?
Personally, I’m fine with J getting the “Solution” since it’s working.
But I would like you to post the full, final working automation. We may need to submit this as an issue on the github, since the behavior of the numeric state trigger template doesn’t seem to conform to the way the documentation says it should be done.