我正在我的Raspberry Pi 3上创建一个google助手,并且我正在尝试创建一个自定义的设备操作,以最终打开我的车库门。它所做的一切就是在这个时间点上玩LED。
这是我的actions.json文件:
{
"manifest": {
"displayName": "Garage door",
"invocationName": "Garage door",
"category": "PRODUCTIVITY"
},
"actions": [
{
"name": "me.custom.actions.GarageDoor",
"availability": {
"deviceClasses": [
{
"assistantSdkDevice": {}
}
]
},
"intent": {
"name": "me.custom.intents.GarageDoor",
"trigger": {
"queryPatterns": [
"open the garage door",
"close the garage door"
]
}
},
"fulfillment": {
"staticFulfillment": {
"templatedResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Okay"
}
},
{
"deviceExecution": {
"command": "me.custom.commands.GarageDoor"
}
}
]
}
}
}
}
],
"types": []
}但是当我运行这个命令时,我得到了这个错误:
INFO:root:Transcript of user request: "open the garage door".
INFO:root:Playing assistant response.
WARNING:root:Error during command execution
Traceback (most recent call last):
File "/home/pi/assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/grpc/device_helpers.py", line 94, in dispatch_command
self.handlers[command](**params)
TypeError: gdoor() argument after ** must be a mapping, not NoneType这是我的处理程序:
@device_handler.command('me.custom.commands.GarageDoor')
def gdoor(*args):
print(args)
global g_open
if g_open:
GPIO.output(18, 0)
g_open = 0
else:
GPIO.output(18, 1)
g_open = 1我尝试了一下*args,看看它是否修复了什么--它没有。为了保护隐私,我已经把我的包名改成了custom。我对此很困惑。感谢任何人的帮助!
谢谢!
发布于 2018-12-04 04:40:15
看看the sample code,看起来函数签名有点不同,因为它直接添加了参数。
@device_handler.command('com.example.commands.BlinkLight')
def blink(speed, number):
logging.info('Blinking device %s times.' % number)
delay = 1
if speed == "SLOWLY":
delay = 2
elif speed == "QUICKLY":
delay = 0.5
for i in range(int(number)):
logging.info('Device is blinking.')
time.sleep(delay)查看操作包,您似乎没有提供任何操作来配合命令执行。如the sample所示
{
"deviceExecution": {
"command": "com.example.commands.BlinkLight",
"params": {
"speed": "$speed",
"number": "$number"
}
}
}如果没有任何参数,它可能根本不会映射任何函数。
https://stackoverflow.com/questions/53585059
复制相似问题