I assume that when you did it in the template editor you did not have those outer quotation marks correct? You have a quotation mark issue, you need to escape the inner ones or use single quotes instead of double quotes either inside or outside. Try this:
So when you said “works in the template editor” i assumed the only issue was quotation marks since the difference between the editor and automations.yaml is you wrap the template in quotation marks. So I pasted this into the template editor on my HA:
Configuration check gives a message stating what is wrong, please paste it in next time it will make this process a lot easier.
Fortunately that can be fixed by adding ) to the end. Unfortunately, that’s still not enough to get this template working in the template editor since now I get Unknown error rendering template. Realized that’s because you’re trying to add an integer to now() which isn’t a meaningful operation.
I can’t really fix your template at this point because I don’t really know what you’re trying to do, adding an integer to a date doesn’t make sense. Since you’re multiplying it by 60 I guess you’re probably either trying to add minutes or hours but I don’t know which. You’re going to have to explain what you want this to do for help making a working template.
EDIT: ok I get it now, you missed a parenthesis in the middle right after now() not at the end. Try this:
If it’s the entire automation, where’s the trigger? It only shows the automation’s action. The template refers to the Trigger State Object but, without seeing the trigger, we can’t be sure it’s being used correctly in the template.
Anyway, I untangled the first template’s spaghetti and it looks like this:
action:
- service: var.set
data_template:
entity_id: var.time_left
value: >
{% set x = states('input_number.smoker_target') | int - states('sensor.maverick_temp1') | int %}
{% set y = trigger.to_state.state | int - trigger.from_state.state | int %}
{% set z = now().timestamp() - states.script.smoker_status.last_updated.timestamp() %}
{{ (x / y * z / 60) | int }}