I would guess if this is not there, then it errors…
So add a test if it’s is there before you do the rest of the template, and it it’s not, do something else or supply a default.
I think I would set it as a variable in the beginning of the jinja. That makes your code MUCH cleaner anyway. And if it doesn’t exist, add a string that will work but tell you the info is not there.
I’m horrible at writing this stuff for others, but there are jinja things to check if things exist.
I wrote this a while back and it would work, but there are easier ways. You could look at what this is doing and try that.
If you have a dashboard open with mushroom template cards on it, if you restart HA from another window, as it redraws the dashboard on the other tab - it fills the logs with errors that don’t actually exist.
Example :
Error while processing template: Template<template=({{states('sensor.office_occupancy')) renders=2>
As you can see that’s incomplete - it throws loads of errors as it goes through the line character by character. Not sure if it’s a HA error or Mushroom. I’ll log against Mushroom first.