diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 8c972a26cc509e..131a51cb6fff8e 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -7,7 +7,7 @@ import base64 import collections.abc from collections.abc import Callable, Generator, Iterable -from contextlib import AbstractContextManager, suppress +from contextlib import AbstractContextManager from contextvars import ContextVar from datetime import date, datetime, time, timedelta from functools import cache, lru_cache, partial, wraps @@ -759,8 +759,10 @@ def async_render_with_possible_json_value( variables = dict(variables or {}) variables["value"] = value - with suppress(*JSON_DECODE_EXCEPTIONS): + try: # noqa: SIM105 - suppress is much slower variables["value_json"] = json_loads(value) + except JSON_DECODE_EXCEPTIONS: + pass try: render_result = _render_with_context(