```
2020-08-07 22:38:10 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.3903193064] local variable 'response' referenced before assignment
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/rest_command/__init__.py", line 115, in async_service_handler
async with getattr(websession, method)(
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 582, in _request
break
File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 586, in __exit__
raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 125, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1281, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1316, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/rest_command/__init__.py", line 137, in async_service_handler
_LOGGER.warning("Timeout call %s", response.url, exc_info=1)
UnboundLocalError: local variable 'response' referenced before assignment
```
* rename request to response, isort and black fixes
* Log exception details
* Add status code to success log, reformat log
* new syntax for response
* changed info to debug
* fix rest_command when server is unreachable
When a server doesn't exist, the connection fails immediately, rather
than waiting for a timeout. This means that the async handler is never
reached, and the request variable never filled, yet it's used in the
client error exception handler, so this one bugs out.
By using the command_config, we avoid using the potentially unassigned
request variable, avoiding this problem.
This patch makes scripts work that have a rest_command in them which
fails due to a server being offline.
* render template_url
instead of printing the template object
* fix formatting
* fix format using black
* only render url once
* blacken...