我正在创建我的(第一个)Lambda 函数。Lambda 旨在打开/关闭飞利浦 HUE 灯泡。Lambda 函数的触发器是 AWS IoT (Dash) 按钮。
但是,在触发我的 Lambda 函数后,我收到以下错误消息:
[ERROR] TypeError: lambda_handler() takes 1 positional argument but 2 were given
Traceback (most recent call last):
File "/var/runtime/bootstrap.py", line 131, in handle_event_request
response = request_handler(event, lambda_context)
任何人都可以提供任何关于我的 Python 代码有什么问题的见解吗?谢谢!
import requests,json
bridgeIP = "PublicIPAddress:999"
userID = "someone"
lightID = "2"
def lambda_handler(lightID):
url = "http://"+bridgeIP+"/api/"+userID+"/lights/"+lightID
r = requests.get(url)
data = json.loads(r.text)
if data["state"]["on"] == False:
r = requests.put(url+"/state",json.dumps({'on':True}))
elif data["state"]["on"] == True:
r = requests.put(url+"/state",json.dumps({'on':False}))
lambda_handler(lightID)
慕村225694
翻阅古今
相关分类