Remove unnecessary assignment of Template.hass from rest (#123682)

This commit is contained in:
Erik Montnemery 2024-08-12 15:52:03 +02:00 committed by GitHub
parent 1c9a1c71d3
commit ecd061d46f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 0 additions and 19 deletions

View file

@ -202,19 +202,14 @@ def create_rest_data_from_config(hass: HomeAssistant, config: ConfigType) -> Res
timeout: int = config[CONF_TIMEOUT]
encoding: str = config[CONF_ENCODING]
if resource_template is not None:
resource_template.hass = hass
resource = resource_template.async_render(parse_result=False)
if payload_template is not None:
payload_template.hass = hass
payload = payload_template.async_render(parse_result=False)
if not resource:
raise HomeAssistantError("Resource not set for RestData")
template.attach(hass, headers)
template.attach(hass, params)
auth: httpx.DigestAuth | tuple[str, str] | None = None
if username and password:
if config.get(CONF_AUTHENTICATION) == HTTP_DIGEST_AUTHENTICATION:

View file

@ -133,8 +133,6 @@ class RestBinarySensor(ManualTriggerEntity, RestEntity, BinarySensorEntity):
)
self._previous_data = None
self._value_template: Template | None = config.get(CONF_VALUE_TEMPLATE)
if (value_template := self._value_template) is not None:
value_template.hass = hass
@property
def available(self) -> bool:

View file

@ -172,7 +172,6 @@ class RestNotificationService(BaseNotificationService):
}
if not isinstance(value, Template):
return value
value.hass = self._hass
return value.async_render(kwargs, parse_result=False)
if self._data:

View file

@ -139,8 +139,6 @@ class RestSensor(ManualTriggerSensorEntity, RestEntity):
config[CONF_FORCE_UPDATE],
)
self._value_template = config.get(CONF_VALUE_TEMPLATE)
if (value_template := self._value_template) is not None:
value_template.hass = hass
self._json_attrs = config.get(CONF_JSON_ATTRS)
self._json_attrs_path = config.get(CONF_JSON_ATTRS_PATH)
self._attr_extra_state_attributes = {}

View file

@ -153,11 +153,6 @@ class RestSwitch(ManualTriggerEntity, SwitchEntity):
self._body_on.hass = hass
self._body_off.hass = hass
if (is_on_template := self._is_on_template) is not None:
is_on_template.hass = hass
template.attach(hass, self._headers)
template.attach(hass, self._params)
async def async_added_to_hass(self) -> None:
"""Handle adding to Home Assistant."""

View file

@ -96,7 +96,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
method = command_config[CONF_METHOD]
template_url = command_config[CONF_URL]
template_url.hass = hass
auth = None
if CONF_USERNAME in command_config:
@ -107,11 +106,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
template_payload = None
if CONF_PAYLOAD in command_config:
template_payload = command_config[CONF_PAYLOAD]
template_payload.hass = hass
template_headers = command_config.get(CONF_HEADERS, {})
for template_header in template_headers.values():
template_header.hass = hass
content_type = command_config.get(CONF_CONTENT_TYPE)