From 4cc4bd3b9a5999a804dcd878148dcf8aadf85bf1 Mon Sep 17 00:00:00 2001 From: Petro31 <35082313+Petro31@users.noreply.github.com> Date: Thu, 24 Jul 2025 17:28:56 -0400 Subject: [PATCH] Remove redundant async_set_context from platforms (#149403) --- homeassistant/components/template/binary_sensor.py | 1 - homeassistant/components/template/cover.py | 1 - homeassistant/components/template/fan.py | 1 - homeassistant/components/template/light.py | 1 - homeassistant/components/template/lock.py | 1 - homeassistant/components/template/switch.py | 1 - homeassistant/components/template/vacuum.py | 1 - 7 files changed, 7 deletions(-) diff --git a/homeassistant/components/template/binary_sensor.py b/homeassistant/components/template/binary_sensor.py index 567e9e3a110..a2c5c7d460a 100644 --- a/homeassistant/components/template/binary_sensor.py +++ b/homeassistant/components/template/binary_sensor.py @@ -370,7 +370,6 @@ class TriggerBinarySensorEntity(TriggerEntity, BinarySensorEntity, RestoreEntity def _set_state(self, state, _=None): """Set up auto off.""" self._attr_is_on = state - self.async_set_context(self.coordinator.data["context"]) self.async_write_ha_state() if not state: diff --git a/homeassistant/components/template/cover.py b/homeassistant/components/template/cover.py index 8f88baea091..e8739fa8207 100644 --- a/homeassistant/components/template/cover.py +++ b/homeassistant/components/template/cover.py @@ -492,7 +492,6 @@ class TriggerCoverEntity(TriggerEntity, AbstractTemplateCover): write_ha_state = True if not self._attr_assumed_state: - self.async_set_context(self.coordinator.data["context"]) write_ha_state = True elif self._attr_assumed_state and len(self._rendered) > 0: # In case any non optimistic template diff --git a/homeassistant/components/template/fan.py b/homeassistant/components/template/fan.py index 13d2414aea2..2d0d06f86a1 100644 --- a/homeassistant/components/template/fan.py +++ b/homeassistant/components/template/fan.py @@ -561,5 +561,4 @@ class TriggerFanEntity(TriggerEntity, AbstractTemplateFan): write_ha_state = True if write_ha_state: - self.async_set_context(self.coordinator.data["context"]) self.async_write_ha_state() diff --git a/homeassistant/components/template/light.py b/homeassistant/components/template/light.py index 802fc145427..07591ce9653 100644 --- a/homeassistant/components/template/light.py +++ b/homeassistant/components/template/light.py @@ -1166,7 +1166,6 @@ class TriggerLightEntity(TriggerEntity, AbstractTemplateLight): raw = self._rendered.get(CONF_STATE) self._state = template.result_as_boolean(raw) - self.async_set_context(self.coordinator.data["context"]) write_ha_state = True elif self._optimistic and len(self._rendered) > 0: # In case any non optimistic template diff --git a/homeassistant/components/template/lock.py b/homeassistant/components/template/lock.py index a2f1f56bea2..848469b0ca4 100644 --- a/homeassistant/components/template/lock.py +++ b/homeassistant/components/template/lock.py @@ -372,7 +372,6 @@ class TriggerLockEntity(TriggerEntity, AbstractTemplateLock): write_ha_state = True if not self._optimistic: - self.async_set_context(self.coordinator.data["context"]) write_ha_state = True elif self._optimistic and len(self._rendered) > 0: # In case any non optimistic template diff --git a/homeassistant/components/template/switch.py b/homeassistant/components/template/switch.py index b1d72084ae7..bd271e4b17c 100644 --- a/homeassistant/components/template/switch.py +++ b/homeassistant/components/template/switch.py @@ -295,7 +295,6 @@ class TriggerSwitchEntity(TriggerEntity, SwitchEntity, RestoreEntity): raw = self._rendered.get(CONF_STATE) self._attr_is_on = template.result_as_boolean(raw) - self.async_set_context(self.coordinator.data["context"]) self.async_write_ha_state() elif self._attr_assumed_state and len(self._rendered) > 0: # In case name, icon, or friendly name have a template but diff --git a/homeassistant/components/template/vacuum.py b/homeassistant/components/template/vacuum.py index 0056eca9b99..5ff99020f0d 100644 --- a/homeassistant/components/template/vacuum.py +++ b/homeassistant/components/template/vacuum.py @@ -404,5 +404,4 @@ class TriggerVacuumEntity(TriggerEntity, AbstractTemplateVacuum): write_ha_state = True if write_ha_state: - self.async_set_context(self.coordinator.data["context"]) self.async_write_ha_state()