diff --git a/homeassistant/components/rest/binary_sensor.py b/homeassistant/components/rest/binary_sensor.py index ec8b3ba0122..c19bfe307d0 100644 --- a/homeassistant/components/rest/binary_sensor.py +++ b/homeassistant/components/rest/binary_sensor.py @@ -84,7 +84,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= if resource_template is not None: resource_template.hass = hass - resource = resource_template.render(parse_result=False) + resource = resource_template.async_render(parse_result=False) if value_template is not None: value_template.hass = hass @@ -189,6 +189,6 @@ class RestBinarySensor(BinarySensorEntity): async def async_update(self): """Get the latest data from REST API and updates the state.""" if self._resource_template is not None: - self.rest.set_url(self._resource_template.render(parse_result=False)) + self.rest.set_url(self._resource_template.async_render(parse_result=False)) await self.rest.async_update() diff --git a/homeassistant/components/rest/sensor.py b/homeassistant/components/rest/sensor.py index 323447ba1b3..826160604ba 100644 --- a/homeassistant/components/rest/sensor.py +++ b/homeassistant/components/rest/sensor.py @@ -103,7 +103,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= if resource_template is not None: resource_template.hass = hass - resource = resource_template.render(parse_result=False) + resource = resource_template.async_render(parse_result=False) if username and password: if config.get(CONF_AUTHENTICATION) == HTTP_DIGEST_AUTHENTICATION: @@ -202,7 +202,7 @@ class RestSensor(Entity): async def async_update(self): """Get the latest data from REST API and update the state.""" if self._resource_template is not None: - self.rest.set_url(self._resource_template.render(parse_result=False)) + self.rest.set_url(self._resource_template.async_render(parse_result=False)) await self.rest.async_update() diff --git a/tests/components/rest/test_binary_sensor.py b/tests/components/rest/test_binary_sensor.py index 276dc293f87..1f2c88f4278 100644 --- a/tests/components/rest/test_binary_sensor.py +++ b/tests/components/rest/test_binary_sensor.py @@ -116,7 +116,7 @@ async def test_setup_minimum_resource_template(hass): { "binary_sensor": { "platform": "rest", - "resource_template": "http://localhost", + "resource_template": "{% set url = 'http://localhost' %}{{ url }}", } }, ) diff --git a/tests/components/rest/test_sensor.py b/tests/components/rest/test_sensor.py index 6a7e444cedd..d841f69e45f 100644 --- a/tests/components/rest/test_sensor.py +++ b/tests/components/rest/test_sensor.py @@ -102,7 +102,7 @@ async def test_setup_minimum_resource_template(hass): { "sensor": { "platform": "rest", - "resource_template": "http://localhost", + "resource_template": "{% set url = 'http://localhost' %}{{ url }}", } }, )