Use text= instead of body= for creating web responses (#20879)

This commit is contained in:
Paulus Schoutsen 2019-02-08 23:10:04 -08:00 committed by Rohan Kapoor
parent 876e2a0a11
commit 33dcb071da
3 changed files with 7 additions and 7 deletions

View File

@ -123,7 +123,7 @@ def _set_location(hass, data, location_name):
) )
return web.Response( return web.Response(
body="Setting location for {}".format(device), text="Setting location for {}".format(device),
status=HTTP_OK status=HTTP_OK
) )

View File

@ -66,7 +66,7 @@ async def handle_webhook(hass, webhook_id, request):
data = WEBHOOK_SCHEMA(dict(await request.post())) data = WEBHOOK_SCHEMA(dict(await request.post()))
except vol.MultipleInvalid as error: except vol.MultipleInvalid as error:
return web.Response( return web.Response(
body=error.error_message, text=error.error_message,
status=HTTP_UNPROCESSABLE_ENTITY status=HTTP_UNPROCESSABLE_ENTITY
) )
@ -91,7 +91,7 @@ async def handle_webhook(hass, webhook_id, request):
) )
return web.Response( return web.Response(
body='Setting location for {}'.format(device), text='Setting location for {}'.format(device),
status=HTTP_OK status=HTTP_OK
) )

View File

@ -101,7 +101,7 @@ async def handle_webhook(hass, webhook_id, request):
location_name location_name
) )
return web.Response( return web.Response(
body='Setting location to not home', text='Setting location to not home',
status=HTTP_OK status=HTTP_OK
) )
@ -110,7 +110,7 @@ async def handle_webhook(hass, webhook_id, request):
# before the previous zone was exited. The enter message will # before the previous zone was exited. The enter message will
# be sent first, then the exit message will be sent second. # be sent first, then the exit message will be sent second.
return web.Response( return web.Response(
body='Ignoring exit from {} (already in {})'.format( text='Ignoring exit from {} (already in {})'.format(
location_name, current_state location_name, current_state
), ),
status=HTTP_OK status=HTTP_OK
@ -120,14 +120,14 @@ async def handle_webhook(hass, webhook_id, request):
# In the app, a test message can be sent. Just return something to # In the app, a test message can be sent. Just return something to
# the user to let them know that it works. # the user to let them know that it works.
return web.Response( return web.Response(
body='Received test message.', text='Received test message.',
status=HTTP_OK status=HTTP_OK
) )
_LOGGER.error('Received unidentified message from Locative: %s', _LOGGER.error('Received unidentified message from Locative: %s',
direction) direction)
return web.Response( return web.Response(
body='Received unidentified message: {}'.format(direction), text='Received unidentified message: {}'.format(direction),
status=HTTP_UNPROCESSABLE_ENTITY status=HTTP_UNPROCESSABLE_ENTITY
) )