Remove unnecessary assignment of Template.hass from event helper (#123777)

This commit is contained in:
Erik Montnemery 2024-08-13 12:09:30 +02:00 committed by GitHub
parent 4ceb9b9dbf
commit 78f7b3340d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 14 deletions

View file

@ -976,8 +976,6 @@ class TrackTemplateResultInfo:
self.hass = hass
self._job = HassJob(action, f"track template result {track_templates}")
for track_template_ in track_templates:
track_template_.template.hass = hass
self._track_templates = track_templates
self._has_super_template = has_super_template

View file

@ -1476,7 +1476,7 @@ async def test_track_template_result_super_template_2(
wildercard_runs = []
wildercard_runs_availability = []
template_availability = Template(availability_template)
template_availability = Template(availability_template, hass)
template_condition = Template("{{states.sensor.test.state}}", hass)
template_condition_var = Template(
"{{(states.sensor.test.state|int) + test }}", hass
@ -1628,7 +1628,7 @@ async def test_track_template_result_super_template_2_initially_false(
wildercard_runs = []
wildercard_runs_availability = []
template_availability = Template(availability_template)
template_availability = Template(availability_template, hass)
template_condition = Template("{{states.sensor.test.state}}", hass)
template_condition_var = Template(
"{{(states.sensor.test.state|int) + test }}", hass
@ -3124,11 +3124,11 @@ async def test_async_track_template_result_multiple_templates(
) -> None:
"""Test tracking multiple templates."""
template_1 = Template("{{ states.switch.test.state == 'on' }}")
template_2 = Template("{{ states.switch.test.state == 'on' }}")
template_3 = Template("{{ states.switch.test.state == 'off' }}")
template_1 = Template("{{ states.switch.test.state == 'on' }}", hass)
template_2 = Template("{{ states.switch.test.state == 'on' }}", hass)
template_3 = Template("{{ states.switch.test.state == 'off' }}", hass)
template_4 = Template(
"{{ states.binary_sensor | map(attribute='entity_id') | list }}"
"{{ states.binary_sensor | map(attribute='entity_id') | list }}", hass
)
refresh_runs = []
@ -3188,11 +3188,12 @@ async def test_async_track_template_result_multiple_templates_mixing_domain(
) -> None:
"""Test tracking multiple templates when tracking entities and an entire domain."""
template_1 = Template("{{ states.switch.test.state == 'on' }}")
template_2 = Template("{{ states.switch.test.state == 'on' }}")
template_3 = Template("{{ states.switch.test.state == 'off' }}")
template_1 = Template("{{ states.switch.test.state == 'on' }}", hass)
template_2 = Template("{{ states.switch.test.state == 'on' }}", hass)
template_3 = Template("{{ states.switch.test.state == 'off' }}", hass)
template_4 = Template(
"{{ states.switch | sort(attribute='entity_id') | map(attribute='entity_id') | list }}"
"{{ states.switch | sort(attribute='entity_id') | map(attribute='entity_id') | list }}",
hass,
)
refresh_runs = []
@ -3417,8 +3418,8 @@ async def test_async_track_template_result_multiple_templates_mixing_listeners(
) -> None:
"""Test tracking multiple templates with mixing listener types."""
template_1 = Template("{{ states.switch.test.state == 'on' }}")
template_2 = Template("{{ now() and True }}")
template_1 = Template("{{ states.switch.test.state == 'on' }}", hass)
template_2 = Template("{{ now() and True }}", hass)
refresh_runs = []