Hi, I hope someone can help with this one I have been using this code to monitor a plug running a washing machine. It’s the code of a manual card which displays an estimated time left.
The code gives lots of errors in the log so I have been trying to resolve them,
With research I have added the default =0 to the as_timestamp function.
So the code now looks like this:
but still getting an error of : TemplateSyntaxError: unexpected ‘}’, expected ‘)’ which I haven’t been able to resolve. I am sure it must be some thing I am missing.
Any help appreciated
Means it’s expecting a ) as it is trying to match pairs. () And {} cannot interleave… it encountered } before encountering the matching )… thus the error is an unexpected } when a ) was expected instead
So am I right in when looking at the top line there is a ) missing at the end ?
like this {% if (as_timestamp(states('input_datetime.washing_stopped'), default=0))
Did u copy the code from elsewhere? Or did u write it yourself? should think through the grouping of the different expressions and what you intend for it to do…
I’m not sure of the purpose of the very first (. Get rid of that?
Hi Armedad, re the code no I didn’t write it myself I got it from [Smart Home Junkie]. but it gives lots of errors in the logs. So I have been working through them and try to resolve them myself and learn at the same time. But this one was beating me.
Hi Armedad, sorry I should have said that, that was what I was doing and I had got to this error in the code but I could not work out the solution was
Do
where did you get that from and why do you have it there? i don’t usually see that and also not completely sure how it helps you here.
but i guess an important question is to step back and understand if you’re just trying to “get this done” or if you are trying to learn this system, you should be sure to understand what you’re doing and why… don’t trial and error your way to it…
Hi Armedad, sorry the slight delay in coming back to you just had to take phone call.
As I said I was using the code and it was giveing errors in the logs. Which I wanted to see if I could fix myself.
I had started to researched the error messages and found solutions to the various errors I was getting. I worked with with each block, and adding the default =0 took the errors away. The error message changed as I worked through each section of code so I thought I was making progress
Hope this makes sense
please post the template block that is giving an error still.
please post only the template block that’s giving an error… use the dev-tools → templates to figure out which block is giving the error. then put that here.
{% if (as_timestamp(states('input_datetime.washing_stopped'), default=0) <
as_timestamp(states('input_datetime.washing_started'), default=0)) and
(states('sensor.washing_machine_expected_time_left') | float(0) >
the default=0 was indeed the issue. if you match the (), you closed off the as_timestamp. so default=0 was no longer being passed to as_timestamp. also i think the very first ( was intended to wrap the whole < compare.