From 43ced677e53b17cdcab0270dd8add3ddcdc3bd65 Mon Sep 17 00:00:00 2001 From: "Etienne C." <59794011+etiennec78@users.noreply.github.com> Date: Thu, 8 Jan 2026 12:03:45 +0100 Subject: [PATCH] Get the polling state of a sensor from a template (#159900) --- homeassistant/helpers/template/__init__.py | 9 ++++++++- tests/helpers/template/test_init.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/template/__init__.py b/homeassistant/helpers/template/__init__.py index b54b462594b..a9a89b64c2a 100644 --- a/homeassistant/helpers/template/__init__.py +++ b/homeassistant/helpers/template/__init__.py @@ -1208,7 +1208,14 @@ def config_entry_attr( if not isinstance(config_entry_id_, str): raise TemplateError("Must provide a config entry ID") - if attr_name not in ("domain", "title", "state", "source", "disabled_by"): + if attr_name not in ( + "domain", + "title", + "state", + "source", + "disabled_by", + "pref_disable_polling", + ): raise TemplateError("Invalid config entry attribute") config_entry = hass.config_entries.async_get_entry(config_entry_id_) diff --git a/tests/helpers/template/test_init.py b/tests/helpers/template/test_init.py index 8189115f539..cdcba0c7af7 100644 --- a/tests/helpers/template/test_init.py +++ b/tests/helpers/template/test_init.py @@ -1721,6 +1721,7 @@ async def test_config_entry_attr(hass: HomeAssistant) -> None: "title": "mock title", "source": config_entries.SOURCE_BLUETOOTH, "disabled_by": config_entries.ConfigEntryDisabler.USER, + "pref_disable_polling": True, } config_entry = MockConfigEntry(**info) config_entry.add_to_hass(hass)