T3m3z / spotprices2ha

Simple copy-paste approach to fetch data from api.spot-hinta.fi (see https://spot-hinta.fi) to Home Assistant. Includes simple sensors and UI elements to ease automation work.
MIT License
111 stars 14 forks source link

rank-automation.yaml Blueprint fails with "TemplateSyntaxError: unexpected char '\\' at 1930" #28

Closed vikohub closed 11 months ago

vikohub commented 12 months ago

Imported the blueprint and based a couple of test automations on it. None will trigger. If triggered manually, they always go to "else" (i.e. turn off the device), and never choose the "on" option.

When I pasted the blueprint code to the Template checker in HA, I get the error mentioned in the title.

A bit of googling suggests that the \ characters are not escaped correctly in the trigger: section; more specifically at

"- platform: template value_template: "{% if on_attribute == \ "

(the first backslash there is the character number 1930)

Any ideas?

vikohub commented 12 months ago

I tested with the older version that does not include the \n newlines. It renders without errors in the Template checker. I am still on 2023.10.5 - perhaps that is the cause?

Still, the automations based on the blueprint fail to trigger

vikohub commented 12 months ago

Hmm, for whatever reason, when I imported the new versions of the blueprints (the newline versions), they looked like this:

Screenshot 2023-11-20 at 15 39 58

I suppose that this was not intended?

Re-importing them after upgrading to 2013.11.2 yielded this (no backslashes):

"... trigger:

Seemed to pass the template checker, but did not trigger correctly at first try.

After toggling the allowed rank above AND below the current rank a few times, the automation finally started to work.

vikohub commented 11 months ago

Seems like the problem was created by copying the code manually from the browser window, and somehow the \n tags got incorporated into the code. The blueprints work fine after re-importing. Closing the issue.