Home Assistant
0.89.2
rest_command.my_request
{
“number”:“12345678”,
“text”:“text”
}
will return
Failed to call service rest_command/my_request. local variable ‘request’ referenced before assignment
or form log file:
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py”, line 148, in handle_call_service
connection.context(msg))
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1133, in async_call
self._execute_service(handler, service_call))
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1155, in _execute_service
await handler.func(service_call)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/rest_command/init.py”, line 113, in async_service_handler
_LOGGER.error(“Client error %s.”, request.url)
UnboundLocalError: local variable ‘request’ referenced before assignment
2019-03-17 21:16:14 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1888877552] local variable ‘request’ referenced before assignment
Traceback (most recent call last):
Test code a simple http server
flask code:
from flask import Flask, request, jsonify
app = Flask(name)
@app.route(’/sms’, methods=[‘POST’])
def send_sms():
content = request.json
print(content[‘number’], content[‘text’])
return “”
if name == ‘main’:
app.run(host= ‘0.0.0.0’,debug=True,port=80)